[llvm] [LAA] Be more careful when evaluating AddRecs at symbolic max BTC. (PR #128061)
    Florian Hahn via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Jun 19 09:12:55 PDT 2025
    
    
  
================
@@ -188,9 +188,91 @@ RuntimeCheckingPtrGroup::RuntimeCheckingPtrGroup(
   Members.push_back(Index);
 }
 
+/// Returns \p A + \p B, if it is guaranteed not to unsigned wrap. Otherwise
+/// return nullptr.
+static const SCEV *addSCEVOverflow(const SCEV *A, const SCEV *B,
+                                   ScalarEvolution &SE) {
+  if (!SE.willNotOverflow(Instruction::Add, false, A, B))
+    return nullptr;
+  return SE.getAddExpr(A, B);
+}
+
+/// Returns \p A * \p B, if it is guaranteed not to unsigned wrap. Otherwise
+/// return nullptr.
+static const SCEV *mulSCEVOverflow(const SCEV *A, const SCEV *B,
+                                   ScalarEvolution &SE) {
+  if (!SE.willNotOverflow(Instruction::Mul, false, A, B))
----------------
fhahn wrote:
Added a comment, thanks. They must have the same type for A * B to be valid.
https://github.com/llvm/llvm-project/pull/128061
    
    
More information about the llvm-commits
mailing list