From 6f07a9e80ab6f3040ae7d8afeaed7f2a207467d2 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sun, 29 Mar 2020 17:25:42 +0200 Subject: [PATCH] [InstCombine] Erase original add when creating saddo Usually when we replaceInstUsesWith() we also return the original instruction, and InstCombine will take care of erasing it. Here we don't do that, so we need to manually erase it. NFC apart from worklist order changes. --- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index d1fa802..f36dcac 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1330,6 +1330,7 @@ static Instruction *processUGT_ADDCST_ADD(ICmpInst &I, Value *A, Value *B, // The inner add was the result of the narrow add, zero extended to the // wider type. Replace it with the result computed by the intrinsic. IC.replaceInstUsesWith(*OrigAdd, ZExt); + IC.eraseInstFromFunction(*OrigAdd); // The original icmp gets replaced with the overflow value. return ExtractValueInst::Create(Call, 1, "sadd.overflow"); -- 2.7.4