Comment Comment by lyinsteve I don’t know much about rust specifically, but the overflow traps happen in debug (i.e. -O0) builds, and are not emitted when optimizations are enabled.LLVM’s constant folding and canonicalization passes will convert (x * 2) / 2 from%0 = mul i64 %x, i64 2%1 = div i64 %0, i64 2to%0 = shl i64 %x, i64 1%1 = shr i64 %0, i64 1Which constant folding will reduce to just %x. parent lyinsteve 8 years ago
LLVM’s constant folding and canonicalization passes will convert (x * 2) / 2 from
%0 = mul i64 %x, i64 2
%1 = div i64 %0, i64 2
to
%0 = shl i64 %x, i64 1
%1 = shr i64 %0, i64 1
Which constant folding will reduce to just %x.