[SCEV] Don't create udiv constant expression (NFC)
authorNikita Popov <npopov@redhat.com>
Wed, 29 Jun 2022 12:34:02 +0000 (14:34 +0200)
committerNikita Popov <npopov@redhat.com>
Wed, 29 Jun 2022 12:35:05 +0000 (14:35 +0200)
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.

llvm/lib/Analysis/ScalarEvolution.cpp

index d64ce5e1b9cf00c166701e4b7b595baa70832b2b..dc48b256cbf4cfec3bcf936e338f3de17ab6f7f6 100644 (file)
@@ -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()));
     }
   }