[llvm] 23a32bc - [SCEVDivision] Remove unnecessary integer casts (NFCI) (#208155)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 04:03:25 PDT 2026


Author: Ryotaro Kasuga
Date: 2026-07-14T11:03:19Z
New Revision: 23a32bcedb91f27ffdac5d6e6bc65a3b19b3b36c

URL: https://github.com/llvm/llvm-project/commit/23a32bcedb91f27ffdac5d6e6bc65a3b19b3b36c
DIFF: https://github.com/llvm/llvm-project/commit/23a32bcedb91f27ffdac5d6e6bc65a3b19b3b36c.diff

LOG: [SCEVDivision] Remove unnecessary integer casts (NFCI) (#208155)

Since #204146 requires callers of SCEVDivision to pass the numerator and
the denominator with the same type, the bitwidth check in
`visitConstant` no longer makes sense.

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolutionDivision.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolutionDivision.cpp b/llvm/lib/Analysis/ScalarEvolutionDivision.cpp
index 8bd5cb9d339b2..1fda62361667c 100644
--- a/llvm/lib/Analysis/ScalarEvolutionDivision.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionDivision.cpp
@@ -111,13 +111,8 @@ void SCEVDivision::visitConstant(const SCEVConstant *Numerator) {
   if (const SCEVConstant *D = dyn_cast<SCEVConstant>(Denominator)) {
     APInt NumeratorVal = Numerator->getAPInt();
     APInt DenominatorVal = D->getAPInt();
-    uint32_t NumeratorBW = NumeratorVal.getBitWidth();
-    uint32_t DenominatorBW = DenominatorVal.getBitWidth();
-
-    if (NumeratorBW > DenominatorBW)
-      DenominatorVal = DenominatorVal.sext(NumeratorBW);
-    else if (NumeratorBW < DenominatorBW)
-      NumeratorVal = NumeratorVal.sext(DenominatorBW);
+    assert(NumeratorVal.getBitWidth() == DenominatorVal.getBitWidth() &&
+           "Numerator and Denominator must have the same bit width");
 
     APInt QuotientVal(NumeratorVal.getBitWidth(), 0);
     APInt RemainderVal(NumeratorVal.getBitWidth(), 0);


        


More information about the llvm-commits mailing list