[llvm] [InstCombine] Create a class to lazily track computed known bits (PR #66611)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 01:39:38 PDT 2023


================
@@ -253,12 +252,13 @@ bool llvm::haveNoCommonBitsSet(const Value *LHS, const Value *RHS,
         match(LHS, m_Not(m_c_Or(m_Specific(A), m_Specific(B)))))
       return true;
   }
-  IntegerType *IT = cast<IntegerType>(LHS->getType()->getScalarType());
-  KnownBits LHSKnown(IT->getBitWidth());
-  KnownBits RHSKnown(IT->getBitWidth());
-  computeKnownBits(LHS, LHSKnown, DL, 0, AC, CxtI, DT, UseInstrInfo);
-  computeKnownBits(RHS, RHSKnown, DL, 0, AC, CxtI, DT, UseInstrInfo);
-  return KnownBits::haveNoCommonBitsSet(LHSKnown, RHSKnown);
+
+  return KnownBits::haveNoCommonBitsSet(
+      LHSCache.getKnownBits(SimplifyQuery(
+          DL, /*TLI*/ nullptr, DT, AC, safeCxtI(LHSCache, CxtI), UseInstrInfo)),
+      RHSCache.getKnownBits(SimplifyQuery(DL, /*TLI*/ nullptr, DT, AC,
+                                          safeCxtI(RHSCache, CxtI),
----------------
nikic wrote:

This will go away when rebasing (same for your comment below).

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


More information about the llvm-commits mailing list