Skip to content

Commit

Permalink
Fix codegen of ctlz and cttz intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Dec 20, 2019
1 parent 8d2db1b commit a528e37
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@ pub fn codegen_intrinsic_call<'tcx>(
let msb_lz = fx.bcx.ins().clz(msb);
let msb_is_zero = fx.bcx.ins().icmp_imm(IntCC::Equal, msb, 0);
let lsb_lz_plus_64 = fx.bcx.ins().iadd_imm(lsb_lz, 64);
fx.bcx.ins().select(msb_is_zero, lsb_lz_plus_64, msb_lz)
let res = fx.bcx.ins().select(msb_is_zero, lsb_lz_plus_64, msb_lz);
fx.bcx.ins().uextend(types::I128, res)
} else {
fx.bcx.ins().clz(arg)
};
Expand All @@ -697,7 +698,8 @@ pub fn codegen_intrinsic_call<'tcx>(
let msb_tz = fx.bcx.ins().ctz(msb);
let lsb_is_zero = fx.bcx.ins().icmp_imm(IntCC::Equal, lsb, 0);
let msb_tz_plus_64 = fx.bcx.ins().iadd_imm(msb_tz, 64);
fx.bcx.ins().select(lsb_is_zero, msb_tz_plus_64, lsb_tz)
let res = fx.bcx.ins().select(lsb_is_zero, msb_tz_plus_64, lsb_tz);
fx.bcx.ins().uextend(types::I128, res)
} else {
fx.bcx.ins().ctz(arg)
};
Expand Down

0 comments on commit a528e37

Please sign in to comment.