[llvm] 6f07a9e - [InstCombine] Erase original add when creating saddo

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 29 09:02:51 PDT 2020


Author: Nikita Popov
Date: 2020-03-29T18:01:32+02:00
New Revision: 6f07a9e80ab6f3040ae7d8afeaed7f2a207467d2

URL: https://github.com/llvm/llvm-project/commit/6f07a9e80ab6f3040ae7d8afeaed7f2a207467d2
DIFF: https://github.com/llvm/llvm-project/commit/6f07a9e80ab6f3040ae7d8afeaed7f2a207467d2.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index d1fa802b6daa..f36dcacdad28 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");


        


More information about the llvm-commits mailing list