[NFC][SCEV] `createNodeForSelectOrPHIViaUMinSeq()`: refactor `i1 cond ? i1 x : i1 C` pattern

https://alive2.llvm.org/ce/z/2Q7Du_
This commit is contained in:
Roman Lebedev 2022-02-10 17:03:26 +03:00
parent 9766a0cca0
commit 576a45f20d
No known key found for this signature in database
GPG Key ID: 083C3EBB4A1689E0
1 changed files with 6 additions and 11 deletions

View File

@ -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())