[PATCH] D81230: Correctly report modified status for LoopIdiomRecognize

serge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 5 01:03:44 PDT 2020


serge-sans-paille created this revision.
serge-sans-paille added reviewers: asbirlea, nikic, foad, jdoerfert.
Herald added subscribers: llvm-commits, jfb, hiraditya.
Herald added a project: LLVM.

Related to https://reviews.llvm.org/D80916


https://reviews.llvm.org/D81230

Files:
  llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp


Index: llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -1088,8 +1088,12 @@
     return false;
   }
 
-  if (avoidLIRForMultiBlockLoop())
+  if (avoidLIRForMultiBlockLoop()) {
+    Expander.clear();
+    RecursivelyDeleteTriviallyDeadInstructions(LoadBasePtr, TLI);
+    RecursivelyDeleteTriviallyDeadInstructions(StoreBasePtr, TLI);
     return false;
+  }
 
   // Okay, everything is safe, we can transform this!
 
@@ -1111,17 +1115,32 @@
     // anything where the alignment isn't at least the element size.
     const MaybeAlign StoreAlign = SI->getAlign();
     const MaybeAlign LoadAlign = LI->getAlign();
-    if (StoreAlign == None || LoadAlign == None)
+    if (StoreAlign == None || LoadAlign == None) {
+      Expander.clear();
+      RecursivelyDeleteTriviallyDeadInstructions(NumBytes, TLI);
+      RecursivelyDeleteTriviallyDeadInstructions(LoadBasePtr, TLI);
+      RecursivelyDeleteTriviallyDeadInstructions(StoreBasePtr, TLI);
       return false;
-    if (*StoreAlign < StoreSize || *LoadAlign < StoreSize)
+    }
+    if (*StoreAlign < StoreSize || *LoadAlign < StoreSize) {
+      Expander.clear();
+      RecursivelyDeleteTriviallyDeadInstructions(NumBytes, TLI);
+      RecursivelyDeleteTriviallyDeadInstructions(LoadBasePtr, TLI);
+      RecursivelyDeleteTriviallyDeadInstructions(StoreBasePtr, TLI);
       return false;
+    }
 
     // If the element.atomic memcpy is not lowered into explicit
     // loads/stores later, then it will be lowered into an element-size
     // specific lib call. If the lib call doesn't exist for our store size, then
     // we shouldn't generate the memcpy.
-    if (StoreSize > TTI->getAtomicMemIntrinsicMaxElementSize())
+    if (StoreSize > TTI->getAtomicMemIntrinsicMaxElementSize()) {
+      Expander.clear();
+      RecursivelyDeleteTriviallyDeadInstructions(NumBytes, TLI);
+      RecursivelyDeleteTriviallyDeadInstructions(LoadBasePtr, TLI);
+      RecursivelyDeleteTriviallyDeadInstructions(StoreBasePtr, TLI);
       return false;
+    }
 
     // Create the call.
     // Note that unordered atomic loads/stores are *required* by the spec to


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81230.268683.patch
Type: text/x-patch
Size: 2292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200605/b429b048/attachment-0001.bin>


More information about the llvm-commits mailing list