Skip to content

Commit 5f8a748

Browse files
committed
fixup! [ConstraintElim] Simplify MinMaxIntrinsic
1 parent 8358992 commit 5f8a748

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,17 +1065,16 @@ void State::addInfoFor(BasicBlock &BB) {
10651065
case Intrinsic::umax:
10661066
case Intrinsic::smin:
10671067
case Intrinsic::smax:
1068+
// TODO: handle llvm.abs as well
1069+
WorkList.push_back(
1070+
FactOrCheck::getCheck(DT.getNode(&BB), cast<CallInst>(&I)));
10681071
// TODO: Check if it is possible to instead only added the min/max facts
10691072
// when simplifying uses of the min/max intrinsics.
10701073
if (!isGuaranteedNotToBePoison(&I))
10711074
break;
10721075
[[fallthrough]];
10731076
case Intrinsic::abs:
10741077
WorkList.push_back(FactOrCheck::getInstFact(DT.getNode(&BB), &I));
1075-
// TODO: handle llvm.abs as well
1076-
if (ID != Intrinsic::abs)
1077-
WorkList.push_back(
1078-
FactOrCheck::getCheck(DT.getNode(&BB), cast<CallInst>(&I)));
10791078
break;
10801079
}
10811080

@@ -1400,26 +1399,21 @@ static bool checkAndReplaceCondition(
14001399
}
14011400

14021401
static bool checkAndReplaceMinMax(MinMaxIntrinsic *MinMax, ConstraintInfo &Info,
1403-
unsigned NumIn, unsigned NumOut,
1404-
Instruction *ContextInst, DominatorTree &DT,
14051402
SmallVectorImpl<Instruction *> &ToRemove) {
14061403
auto ReplaceMinMaxWithOperand = [&](MinMaxIntrinsic *MinMax, bool UseLHS) {
14071404
// TODO: generate reproducer for min/max.
14081405
MinMax->replaceAllUsesWith(MinMax->getOperand(UseLHS ? 0 : 1));
1409-
if (MinMax->use_empty())
1410-
ToRemove.push_back(MinMax);
1406+
ToRemove.push_back(MinMax);
14111407
return true;
14121408
};
14131409

14141410
ICmpInst::Predicate Pred =
14151411
ICmpInst::getNonStrictPredicate(MinMax->getPredicate());
1416-
if (auto ImpliedCondition =
1417-
checkCondition(Pred, MinMax->getOperand(0), MinMax->getOperand(1),
1418-
MinMax, Info, NumIn, NumOut, ContextInst))
1412+
if (auto ImpliedCondition = checkCondition(
1413+
Pred, MinMax->getOperand(0), MinMax->getOperand(1), MinMax, Info))
14191414
return ReplaceMinMaxWithOperand(MinMax, *ImpliedCondition);
1420-
if (auto ImpliedCondition =
1421-
checkCondition(Pred, MinMax->getOperand(1), MinMax->getOperand(0),
1422-
MinMax, Info, NumIn, NumOut, ContextInst))
1415+
if (auto ImpliedCondition = checkCondition(
1416+
Pred, MinMax->getOperand(1), MinMax->getOperand(0), MinMax, Info))
14231417
return ReplaceMinMaxWithOperand(MinMax, !*ImpliedCondition);
14241418
return false;
14251419
}
@@ -1725,8 +1719,7 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
17251719
}
17261720
Changed |= Simplified;
17271721
} else if (auto *MinMax = dyn_cast<MinMaxIntrinsic>(Inst)) {
1728-
Changed |= checkAndReplaceMinMax(MinMax, Info, CB.NumIn, CB.NumOut,
1729-
CB.getContextInst(), S.DT, ToRemove);
1722+
Changed |= checkAndReplaceMinMax(MinMax, Info, ToRemove);
17301723
}
17311724
continue;
17321725
}

0 commit comments

Comments
 (0)