// Check if an integer or vector contains a nonzero element.
Check if an integer or vector contains a nonzero element.
Check if an integer or vector contains a nonzero element .
fn build_nonzero_check<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                   value: ValueRef,
                                   binop_debug_loc: DebugLoc) -> ValueRef {
    let llty = val_ty(value);
    let kind = llty.kind();
    match kind {
        TypeKind::Integer => ICmp(bcx, llvm::IntNE, value, C_null(llty), binop_debug_loc),
        TypeKind::Vector => {
            // Check if any elements of the vector are nonzero by treating
            // it as a wide integer and checking if the integer is nonzero.
            let width = llty.vector_length() as u64 * llty.element_type().int_width();
            let int_value = BitCast(bcx, value, Type::ix(bcx.ccx(), width));
            build_nonzero_check(bcx, int_value, binop_debug_loc)
        },
        _ => panic!("build_nonzero_check: expected Integer or Vector, found {:?}", kind),
    }
}
fn build_nonzero_check < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > , value : ValueRef , binop_debug_loc : DebugLoc ) -> ValueRef { let llty = val_ty ( value ) ; let kind = llty . kind ( ) ; match kind { TypeKind :: Integer => ICmp ( bcx , llvm :: IntNE , value , C_null ( llty ) , binop_debug_loc ) , TypeKind :: Vector => { // Check if any elements of the vector are nonzero by treating // it as a wide integer and checking if the integer is nonzero. let width = llty . vector_length ( ) as u64 * llty . element_type ( ) . int_width ( ) ; let int_value = BitCast ( bcx , value , Type :: ix ( bcx . ccx ( ) , width ) ) ; build_nonzero_check ( bcx , int_value , binop_debug_loc ) } , _ => panic ! ( " " kind ) , } }
Check if an integer or vector contains a nonzero element.
Check if an integer or vector contains a nonzero element .
bcx
Block<'blk, 'tcx>
value
ValueRef
binop_debug_loc
DebugLoc