[llvm] [InstCombine] Generate better code for `std::bit_floor` from libstdc++ (PR #144842)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 22 16:08:56 PDT 2025


================
@@ -3911,6 +3911,80 @@ static Value *foldSelectBitTest(SelectInst &Sel, Value *CondVal, Value *TrueVal,
   return nullptr;
 }
 
+// Transform:
+//
+//   1 << (C - ctlz(X >> 1))
+//
+// into
+//
+//   (1 << (C - 1)) >> ctlz(X)
----------------
kazutakahirata wrote:

Could you update this comment with the mask?

Maybe you can even mention that the mask is free on many machines.


https://github.com/llvm/llvm-project/pull/144842


More information about the llvm-commits mailing list