[llvm] [InstCombine] Canonicalize Bit Testing by Shifting to Sign Bit (PR #101822)

via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 3 10:40:16 PDT 2024


================
@@ -1725,7 +1725,8 @@ Instruction *InstCombinerImpl::foldICmpAndShift(ICmpInst &Cmp,
   // preferable because it allows the C2 << Y expression to be hoisted out of a
   // loop if Y is invariant and X is not.
   if (Shift->hasOneUse() && C1.isZero() && Cmp.isEquality() &&
-      !Shift->isArithmeticShift() && !isa<Constant>(Shift->getOperand(0))) {
+      !Shift->isArithmeticShift() &&
+      ((!IsShl && C2.isOne()) || !isa<Constant>(Shift->getOperand(0)))) {
----------------
mskamp wrote:

Sure. Here we go: https://github.com/llvm/llvm-project/pull/101838

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


More information about the llvm-commits mailing list