Skip to content

Commit e48fe76

Browse files
authored
[InstCombine] Remove foldSelectWithFrozenICmp() fold (llvm#161659)
After llvm#154336 this fold no longer triggers, as the freeze will be pushed through to the icmp operands, and generic handling will take care of it.
1 parent 1c1d525 commit e48fe76

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,32 +2934,6 @@ static Instruction *foldSelectWithSRem(SelectInst &SI, InstCombinerImpl &IC,
29342934
return nullptr;
29352935
}
29362936

2937-
static Value *foldSelectWithFrozenICmp(SelectInst &Sel, InstCombiner::BuilderTy &Builder) {
2938-
FreezeInst *FI = dyn_cast<FreezeInst>(Sel.getCondition());
2939-
if (!FI)
2940-
return nullptr;
2941-
2942-
Value *Cond = FI->getOperand(0);
2943-
Value *TrueVal = Sel.getTrueValue(), *FalseVal = Sel.getFalseValue();
2944-
2945-
// select (freeze(x == y)), x, y --> y
2946-
// select (freeze(x != y)), x, y --> x
2947-
// The freeze should be only used by this select. Otherwise, remaining uses of
2948-
// the freeze can observe a contradictory value.
2949-
// c = freeze(x == y) ; Let's assume that y = poison & x = 42; c is 0 or 1
2950-
// a = select c, x, y ;
2951-
// f(a, c) ; f(poison, 1) cannot happen, but if a is folded
2952-
// ; to y, this can happen.
2953-
CmpPredicate Pred;
2954-
if (FI->hasOneUse() &&
2955-
match(Cond, m_c_ICmp(Pred, m_Specific(TrueVal), m_Specific(FalseVal))) &&
2956-
(Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE)) {
2957-
return Pred == ICmpInst::ICMP_EQ ? FalseVal : TrueVal;
2958-
}
2959-
2960-
return nullptr;
2961-
}
2962-
29632937
/// Given that \p CondVal is known to be \p CondIsTrue, try to simplify \p SI.
29642938
static Value *simplifyNestedSelectsUsingImpliedCond(SelectInst &SI,
29652939
Value *CondVal,
@@ -4446,9 +4420,6 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
44464420
if (Instruction *PN = foldSelectToPhi(SI, DT, Builder))
44474421
return replaceInstUsesWith(SI, PN);
44484422

4449-
if (Value *Fr = foldSelectWithFrozenICmp(SI, Builder))
4450-
return replaceInstUsesWith(SI, Fr);
4451-
44524423
if (Value *V = foldRoundUpIntegerWithPow2Alignment(SI, Builder))
44534424
return replaceInstUsesWith(SI, V);
44544425

0 commit comments

Comments
 (0)