[llvm-branch-commits] [llvm] [SCEVDivision] Add assertion to check operand types match (NFCI) (PR #204146)

Ryotaro Kasuga via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jun 19 01:13:48 PDT 2026


https://github.com/kasuga-fj updated https://github.com/llvm/llvm-project/pull/204146

>From 819a7af565cfbd002ac734cf289bc94b84e8bf2c Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
Date: Tue, 16 Jun 2026 13:18:33 +0000
Subject: [PATCH 1/2] [SCEVDivision] Add assertion to check operand types match

---
 llvm/lib/Analysis/ScalarEvolutionDivision.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Analysis/ScalarEvolutionDivision.cpp b/llvm/lib/Analysis/ScalarEvolutionDivision.cpp
index 710473191f8c6..8bd5cb9d339b2 100644
--- a/llvm/lib/Analysis/ScalarEvolutionDivision.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionDivision.cpp
@@ -56,6 +56,8 @@ void SCEVDivision::divide(ScalarEvolution &SE, const SCEV *Numerator,
                           const SCEV *Denominator, const SCEV **Quotient,
                           const SCEV **Remainder) {
   assert(Numerator && Denominator && "Uninitialized SCEV");
+  assert(Numerator->getType() == Denominator->getType() &&
+         "Numerator and Denominator must have the same type");
 
   SCEVDivision D(SE, Numerator, Denominator);
 

>From d0b35526ea854ba57430e27cffe284fa01254ac6 Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
Date: Fri, 19 Jun 2026 17:13:32 +0900
Subject: [PATCH 2/2] delete unnecessary return

---
 llvm/lib/Analysis/Delinearization.cpp | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/llvm/lib/Analysis/Delinearization.cpp b/llvm/lib/Analysis/Delinearization.cpp
index c0e697cd1b477..5b525b43e4931 100644
--- a/llvm/lib/Analysis/Delinearization.cpp
+++ b/llvm/lib/Analysis/Delinearization.cpp
@@ -72,14 +72,10 @@ struct SCEVCollectTerms {
 
   bool follow(const SCEV *S) {
     if (isa<SCEVUnknown>(S) || isa<SCEVMulExpr>(S) ||
-        isa<SCEVSignExtendExpr>(S)) {
+        isa<SCEVSignExtendExpr>(S))
       if (!containsUndefs(S))
         Terms.push_back(S);
 
-      // Stop recursion: once we collected a term, do not walk its operands.
-      return false;
-    }
-
     // Keep looking when S is a specific type expression.
     return isa<SCEVAddExpr, SCEVAddRecExpr>(S);
   }
@@ -154,8 +150,6 @@ struct SCEVCollectAddRecMultiplies {
         return false;
 
       Terms.push_back(SE.getMulExpr(Operands));
-      // Stop recursion: once we collected a term, do not walk its operands.
-      return false;
     }
 
     // Keep looking when S is a specific type expression.



More information about the llvm-branch-commits mailing list