[llvm] a473c45 - [NFC][SCEV] `createNodeForSelectOrPHIInstWithICmpInstCond()`: dedup eq/ne pred handling
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 11 10:58:32 PST 2022
Author: Roman Lebedev
Date: 2022-02-11T21:58:19+03:00
New Revision: a473c457f6aa7a5d734aef5a325eae30dd9e22e0
URL: https://github.com/llvm/llvm-project/commit/a473c457f6aa7a5d734aef5a325eae30dd9e22e0
DIFF: https://github.com/llvm/llvm-project/commit/a473c457f6aa7a5d734aef5a325eae30dd9e22e0.diff
LOG: [NFC][SCEV] `createNodeForSelectOrPHIInstWithICmpInstCond()`: dedup eq/ne pred handling
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 1f6767c894f3..8b479da3dfcf 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -5952,19 +5952,9 @@ const SCEV *ScalarEvolution::createNodeForSelectOrPHIInstWithICmpInstCond(
}
break;
case ICmpInst::ICMP_NE:
- // n != 0 ? n+x : 1+x -> umax(n, 1)+x
- if (getTypeSizeInBits(LHS->getType()) <= getTypeSizeInBits(I->getType()) &&
- isa<ConstantInt>(RHS) && cast<ConstantInt>(RHS)->isZero()) {
- const SCEV *One = getOne(I->getType());
- const SCEV *LS = getNoopOrZeroExtend(getSCEV(LHS), I->getType());
- const SCEV *LA = getSCEV(TrueVal);
- const SCEV *RA = getSCEV(FalseVal);
- const SCEV *LDiff = getMinusSCEV(LA, LS);
- const SCEV *RDiff = getMinusSCEV(RA, One);
- if (LDiff == RDiff)
- return getAddExpr(getUMaxExpr(One, LS), LDiff);
- }
- break;
+ // n != 0 ? n+x : 1+x -> n == 0 ? 1+x : n+x
+ std::swap(TrueVal, FalseVal);
+ LLVM_FALLTHROUGH;
case ICmpInst::ICMP_EQ:
// n == 0 ? 1+x : n+x -> umax(n, 1)+x
if (getTypeSizeInBits(LHS->getType()) <= getTypeSizeInBits(I->getType()) &&
More information about the llvm-commits
mailing list