[SCEV] Recognize `cond ? i1 0 : i1 y` as `umin_seq ~cond, x`

By definition, `umin_seq` has the exact same
poison stopping properties the original `select` had:
https://alive2.llvm.org/ce/z/N6XwV-
This commit is contained in:
Roman Lebedev 2022-02-10 16:46:34 +03:00
parent 418604fd90
commit 9766a0cca0
No known key found for this signature in database
GPG Key ID: 083C3EBB4A1689E0
2 changed files with 8 additions and 1 deletions

View File

@ -6015,6 +6015,13 @@ const SCEV *ScalarEvolution::createNodeForSelectOrPHIViaUMinSeq(
/*Sequential=*/true));
}
// i1 cond ? i1 0 : i1 y --> umin_seq ~cond, y
if (auto *TrueConst = dyn_cast<ConstantInt>(TrueVal)) {
if (TrueConst->isZero())
return getUMinExpr(getNotSCEV(getSCEV(Cond)), getSCEV(FalseVal),
/*Sequential=*/true);
}
return getUnknown(V);
}

View File

@ -158,7 +158,7 @@ define i1 @select_false_or_x(i1 %c, i1 %x) {
; CHECK-LABEL: 'select_false_or_x'
; CHECK-NEXT: Classifying expressions for: @select_false_or_x
; CHECK-NEXT: %r = select i1 %c, i1 false, i1 %x
; CHECK-NEXT: --> %r U: full-set S: full-set
; CHECK-NEXT: --> ((true + %c) umin_seq %x) U: full-set S: full-set
; CHECK-NEXT: Determining loop execution counts for: @select_false_or_x
;
%r = select i1 %c, i1 false, i1 %x