[llvm] 6dd8ec6 - [SCEV] Work on APInt instead of ConstantExpr (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 28 06:24:06 PDT 2023
Author: Nikita Popov
Date: 2023-09-28T15:23:58+02:00
New Revision: 6dd8ec64653ab414cb12ad62924e521f87e5cd52
URL: https://github.com/llvm/llvm-project/commit/6dd8ec64653ab414cb12ad62924e521f87e5cd52
DIFF: https://github.com/llvm/llvm-project/commit/6dd8ec64653ab414cb12ad62924e521f87e5cd52.diff
LOG: [SCEV] Work on APInt instead of ConstantExpr (NFC)
Avoid an unnecessary use of ConstantExpr::getZExt() when
APInt::zext() is sufficient.
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 4e5157970dc0719..9ffffcc018cb577 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -1571,8 +1571,7 @@ const SCEV *ScalarEvolution::getZeroExtendExprImpl(const SCEV *Op, Type *Ty,
// Fold if the operand is constant.
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(Op))
- return getConstant(
- cast<ConstantInt>(ConstantExpr::getZExt(SC->getValue(), Ty)));
+ return getConstant(SC->getAPInt().zext(getTypeSizeInBits(Ty)));
// zext(zext(x)) --> zext(x)
if (const SCEVZeroExtendExpr *SZ = dyn_cast<SCEVZeroExtendExpr>(Op))
@@ -1908,8 +1907,7 @@ const SCEV *ScalarEvolution::getSignExtendExprImpl(const SCEV *Op, Type *Ty,
// Fold if the operand is constant.
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(Op))
- return getConstant(
- cast<ConstantInt>(ConstantExpr::getSExt(SC->getValue(), Ty)));
+ return getConstant(SC->getAPInt().sext(getTypeSizeInBits(Ty)));
// sext(sext(x)) --> sext(x)
if (const SCEVSignExtendExpr *SS = dyn_cast<SCEVSignExtendExpr>(Op))
More information about the llvm-commits
mailing list