[llvm] [CmpInstAnalysis] Return decomposed bit test as struct (NFC) (PR #109819)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 11:59:06 PDT 2024


================
@@ -2465,10 +2465,16 @@ static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, Value *&BaseX,
   };
   auto MatchDecomposableConstantBitMask = [&]() {
     APInt Mask;
-    return llvm::decomposeBitTestICmp(CmpLHS, CmpRHS, Pred, CurrX, Mask) &&
-           ICmpInst::isEquality(Pred) && Mask.isPowerOf2() &&
-           (BitMask = ConstantInt::get(CurrX->getType(), Mask)) &&
-           (BitPos = ConstantInt::get(CurrX->getType(), Mask.logBase2()));
+    auto Res = llvm::decomposeBitTestICmp(CmpLHS, CmpRHS, Pred);
+    if (Res && Res->Mask.isPowerOf2()) {
+      assert(ICmpInst::isEquality(Res->Pred));
----------------
nikic wrote:

decomposeBitTestICmp() is required to always return an equality predicate.

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


More information about the llvm-commits mailing list