From: Roman Lebedev Date: Sat, 29 Aug 2020 11:59:09 +0000 (+0300) Subject: [InstCombine] canonicalizeICmpPredicate(): use InstCombiner::replaceInstUsesWith... X-Git-Tag: llvmorg-13-init~13347 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e65f2131782bc39ec66fc9c74991ff6c2ff1d93b;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index c6017b4..ea955b3 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -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(U)->swapSuccessors(); // swaps prof metadata too break; case Instruction::Xor: - U->replaceAllUsesWith(&I); + replaceInstUsesWith(cast(*U), &I); break; default: llvm_unreachable("Got unexpected user - out of sync with " diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h index 86b0bfe..a03cb5e 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -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);