[llvm] 576a45f - [NFC][SCEV] `createNodeForSelectOrPHIViaUMinSeq()`: refactor `i1 cond ? i1 x : i1 C` pattern
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 10 06:47:17 PST 2022
Author: Roman Lebedev
Date: 2022-02-10T17:42:55+03:00
New Revision: 576a45f20d015de54f99bed5719536adfa0e7738
URL: https://github.com/llvm/llvm-project/commit/576a45f20d015de54f99bed5719536adfa0e7738
DIFF: https://github.com/llvm/llvm-project/commit/576a45f20d015de54f99bed5719536adfa0e7738.diff
LOG: [NFC][SCEV] `createNodeForSelectOrPHIViaUMinSeq()`: refactor `i1 cond ? i1 x : i1 C` pattern
https://alive2.llvm.org/ce/z/2Q7Du_
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 86eeb518f9a1..ff38ef4a7c30 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -5994,10 +5994,12 @@ const SCEV *ScalarEvolution::createNodeForSelectOrPHIViaUMinSeq(
!FalseVal->getType()->isIntegerTy(1))
return getUnknown(V);
- // i1 cond ? i1 x : i1 0 --> umin_seq cond, x
- if (auto *FalseConst = dyn_cast<ConstantInt>(FalseVal)) {
- if (FalseConst->isZero())
- return getUMinExpr(getSCEV(Cond), getSCEV(TrueVal), /*Sequential=*/true);
+ // i1 cond ? i1 x : i1 C --> C + (umin_seq cond, x + C)
+ if (isa<ConstantInt>(FalseVal)) {
+ const SCEV *C = getSCEV(FalseVal);
+ return getAddExpr(C, getUMinExpr(getSCEV(Cond),
+ getAddExpr(C, getSCEV(TrueVal)),
+ /*Sequential=*/true));
}
// i1 cond ? i1 1 : i1 y --> ~umin_seq ~cond, ~y
@@ -6008,13 +6010,6 @@ const SCEV *ScalarEvolution::createNodeForSelectOrPHIViaUMinSeq(
/*Sequential=*/true));
}
- // i1 cond ? i1 x : i1 1 --> ~umin_seq cond, ~x
- if (auto *FalseConst = dyn_cast<ConstantInt>(FalseVal)) {
- if (FalseConst->isOne())
- return getNotSCEV(getUMinExpr(getSCEV(Cond), getNotSCEV(getSCEV(TrueVal)),
- /*Sequential=*/true));
- }
-
// i1 cond ? i1 0 : i1 y --> umin_seq ~cond, y
if (auto *TrueConst = dyn_cast<ConstantInt>(TrueVal)) {
if (TrueConst->isZero())
More information about the llvm-commits
mailing list