[llvm] 30ea6a0 - [SCEV] Don't create udiv constant expression (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 05:35:13 PDT 2022


Author: Nikita Popov
Date: 2022-06-29T14:35:05+02:00
New Revision: 30ea6a06364c4aad1175f2d1440a1ee2ffd8d3e0

URL: https://github.com/llvm/llvm-project/commit/30ea6a06364c4aad1175f2d1440a1ee2ffd8d3e0
DIFF: https://github.com/llvm/llvm-project/commit/30ea6a06364c4aad1175f2d1440a1ee2ffd8d3e0.diff

LOG: [SCEV] Don't create udiv constant expression (NFC)

Work on APInts to make it clear that this will not create a
constant expression.

This code path is not reached if the RHS is zero.

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index d64ce5e1b9cf0..dc48b256cbf4c 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -3480,12 +3480,8 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
       }
 
       // Fold if both operands are constant.
-      if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(LHS)) {
-        Constant *LHSCV = LHSC->getValue();
-        Constant *RHSCV = RHSC->getValue();
-        return getConstant(cast<ConstantInt>(ConstantExpr::getUDiv(LHSCV,
-                                                                   RHSCV)));
-      }
+      if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(LHS))
+        return getConstant(LHSC->getAPInt().udiv(RHSC->getAPInt()));
     }
   }
 


        


More information about the llvm-commits mailing list