Without this patch, std::bit_floor<uint32_t> in libstdc++ is compiled
as:
%eq0 = icmp eq i32 %x, 0 %lshr = lshr i32 %x, 1 %ctlz = tail call i32 @llvm.ctlz.i32(i32 %lshr, i1 false) %sub = sub i32 32, %ctlz %shl = shl i32 1, %sub %sel = select i1 %eq0, i32 0, i32 %shl
With this patch:
%eq0 = icmp eq i32 %x, 0 %ctlz = call i32 @llvm.ctlz.i32(i32 %x, i1 false) %lshr = lshr i32 -2147483648, %1 %sel = select i1 %eq0, i32 0, i32 %lshr
This patch recognizes the specific pattern emitted for std::bit_floor
in libstdc++.
https://alive2.llvm.org/ce/z/piMdFX
This patch fixes:
'32' -> 'BitWidth'.