[llvm] [SCEV] Check if predicate is known false for predicated AddRecs. (PR #151134)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 6 06:02:19 PDT 2025


================
@@ -2328,12 +2335,12 @@ bool ScalarEvolution::willNotOverflow(Instruction::BinaryOps BinOp, bool Signed,
   auto *WideTy =
       IntegerType::get(NarrowTy->getContext(), NarrowTy->getBitWidth() * 2);
 
-  const SCEV *A = (this->*Extension)(
-      (this->*Operation)(LHS, RHS, SCEV::FlagAnyWrap, 0), WideTy, 0);
-  const SCEV *LHSB = (this->*Extension)(LHS, WideTy, 0);
-  const SCEV *RHSB = (this->*Extension)(RHS, WideTy, 0);
-  const SCEV *B = (this->*Operation)(LHSB, RHSB, SCEV::FlagAnyWrap, 0);
-  if (A == B)
+  const SCEV *A = (SE->*Extension)(
+      (SE->*Operation)(LHS, RHS, SCEV::FlagAnyWrap, 0), WideTy, 0);
+  const SCEV *LHSB = (SE->*Extension)(LHS, WideTy, 0);
+  const SCEV *RHSB = (SE->*Extension)(RHS, WideTy, 0);
+  const SCEV *B = (SE->*Operation)(LHSB, RHSB, SCEV::FlagAnyWrap, 0);
+  if (Check == OverflowCheckTy::WillNotOverflow && A == B)
----------------
nikic wrote:

I'm confused by the checkOverflow refactor / usage. It looks like the main analysis is disabled for WillOverflow, only the CtxI-based analysis is performed in that case. However, the usage of checkOverflow() with WillOverflow does not pass CtxI. So I think all the checkOverflow() related changes are just dead code?

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


More information about the llvm-commits mailing list