[InstCombine] canonicalizeICmpPredicate(): use InstCombiner::replaceInstUsesWith() instead of RAUW

We really shouldn't use RAUW in InstCombine
because we should consistently update Worklist to avoid extra iterations.
This commit is contained in:
Roman Lebedev 2020-08-29 14:59:09 +03:00
parent bd12113f57
commit e65f213178
No known key found for this signature in database
GPG Key ID: 083C3EBB4A1689E0
2 changed files with 3 additions and 2 deletions

View File

@ -5306,7 +5306,7 @@ static ICmpInst *canonicalizeCmpWithConstant(ICmpInst &I) {
/// If we have a comparison with a non-canonical predicate, if we can update
/// all the users, invert the predicate and adjust all the users.
static CmpInst *canonicalizeICmpPredicate(CmpInst &I) {
CmpInst *InstCombinerImpl::canonicalizeICmpPredicate(CmpInst &I) {
// Is the predicate already canonical?
CmpInst::Predicate Pred = I.getPredicate();
if (InstCombiner::isCanonicalPredicate(Pred))
@ -5334,7 +5334,7 @@ static CmpInst *canonicalizeICmpPredicate(CmpInst &I) {
cast<BranchInst>(U)->swapSuccessors(); // swaps prof metadata too
break;
case Instruction::Xor:
U->replaceAllUsesWith(&I);
replaceInstUsesWith(cast<Instruction>(*U), &I);
break;
default:
llvm_unreachable("Got unexpected user - out of sync with "

View File

@ -120,6 +120,7 @@ public:
Instruction *visitLShr(BinaryOperator &I);
Instruction *commonShiftTransforms(BinaryOperator &I);
Instruction *visitFCmpInst(FCmpInst &I);
CmpInst *canonicalizeICmpPredicate(CmpInst &I);
Instruction *visitICmpInst(ICmpInst &I);
Instruction *FoldShiftByConstant(Value *Op0, Constant *Op1,
BinaryOperator &I);