forked from OSchip/llvm-project
[InstCombine] Erase old mul when creating umulo
As we don't return the result of replaceInstUsesWith(), we are responsible for erasing the instruction. There is a small subtlety here in that we need to do this after the other uses of Builder, which uses the original multiply as the insertion point. NFC apart from worklist order changes.
This commit is contained in:
parent
53d209076a
commit
8253a86b65
|
@ -3671,6 +3671,11 @@ Value *InstCombiner::foldUnsignedMultiplicationOverflowCheck(ICmpInst &I) {
|
|||
if (NeedNegation) // This technically increases instruction count.
|
||||
Res = Builder.CreateNot(Res, "umul.not.ov");
|
||||
|
||||
// If we replaced the mul, erase it. Do this after all uses of Builder,
|
||||
// as the mul is used as insertion point.
|
||||
if (MulHadOtherUses)
|
||||
eraseInstFromFunction(*Mul);
|
||||
|
||||
return Res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue