@@ -1065,17 +1065,16 @@ void State::addInfoFor(BasicBlock &BB) {
1065
1065
case Intrinsic::umax:
1066
1066
case Intrinsic::smin:
1067
1067
case Intrinsic::smax:
1068
+ // TODO: handle llvm.abs as well
1069
+ WorkList.push_back(
1070
+ FactOrCheck::getCheck(DT.getNode(&BB), cast<CallInst>(&I)));
1068
1071
// TODO: Check if it is possible to instead only added the min/max facts
1069
1072
// when simplifying uses of the min/max intrinsics.
1070
1073
if (!isGuaranteedNotToBePoison(&I))
1071
1074
break;
1072
1075
[[fallthrough]];
1073
1076
case Intrinsic::abs:
1074
1077
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)));
1079
1078
break;
1080
1079
}
1081
1080
@@ -1400,26 +1399,21 @@ static bool checkAndReplaceCondition(
1400
1399
}
1401
1400
1402
1401
static bool checkAndReplaceMinMax(MinMaxIntrinsic *MinMax, ConstraintInfo &Info,
1403
- unsigned NumIn, unsigned NumOut,
1404
- Instruction *ContextInst, DominatorTree &DT,
1405
1402
SmallVectorImpl<Instruction *> &ToRemove) {
1406
1403
auto ReplaceMinMaxWithOperand = [&](MinMaxIntrinsic *MinMax, bool UseLHS) {
1407
1404
// TODO: generate reproducer for min/max.
1408
1405
MinMax->replaceAllUsesWith(MinMax->getOperand(UseLHS ? 0 : 1));
1409
- if (MinMax->use_empty())
1410
- ToRemove.push_back(MinMax);
1406
+ ToRemove.push_back(MinMax);
1411
1407
return true;
1412
1408
};
1413
1409
1414
1410
ICmpInst::Predicate Pred =
1415
1411
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))
1419
1414
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))
1423
1417
return ReplaceMinMaxWithOperand(MinMax, !*ImpliedCondition);
1424
1418
return false;
1425
1419
}
@@ -1725,8 +1719,7 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
1725
1719
}
1726
1720
Changed |= Simplified;
1727
1721
} 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);
1730
1723
}
1731
1724
continue;
1732
1725
}
0 commit comments