[PATCH] D86816: [LoopDelete][Assume] Allow deleting loops with assumes

Tyker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 26 03:34:13 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d5b289a4681: [LoopDelete][Assume] Allow deleting loops with assumes (authored by Tyker).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86816/new/

https://reviews.llvm.org/D86816

Files:
  llvm/lib/Transforms/Scalar/LoopDeletion.cpp
  llvm/test/Transforms/LoopDeletion/assume.ll


Index: llvm/test/Transforms/LoopDeletion/assume.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LoopDeletion/assume.ll
@@ -0,0 +1,40 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt %s -passes=loop-deletion -S | FileCheck %s --check-prefixes=CHECK
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%class.Loc.95 = type { %class.Domain.96 }
+%class.Domain.96 = type { %class.DomainBase.97 }
+%class.DomainBase.97 = type { [3 x %struct.WrapNoInit] }
+%struct.WrapNoInit = type { %class.Loc }
+%class.Loc = type { %class.Domain.67 }
+%class.Domain.67 = type { %class.DomainBase.68 }
+%class.DomainBase.68 = type { i32 }
+
+define dso_local void @_ZSt8_DestroyIP3LocILi3EES1_EvT_S3_RSaIT0_E(%class.Loc.95* %0) #0 {
+; CHECK-LABEL: @_ZSt8_DestroyIP3LocILi3EES1_EvT_S3_RSaIT0_E(
+; CHECK-NEXT:    br label [[_ZST8_DESTROYIP3LOCILI3EEEVT_S3__EXIT:%.*]]
+; CHECK:       _ZSt8_DestroyIP3LocILi3EEEvT_S3_.exit:
+; CHECK-NEXT:    ret void
+;
+  br label %2
+
+2:                                                ; preds = %4, %1
+  %.0.i.i = phi %class.Loc.95* [ undef, %1 ], [ %5, %4 ]
+  %3 = icmp ne %class.Loc.95* %.0.i.i, %0
+  br i1 %3, label %4, label %_ZSt8_DestroyIP3LocILi3EEEvT_S3_.exit
+
+4:                                                ; preds = %2
+  call void @llvm.assume(i1 true) [ "align"(%class.Loc.95* %.0.i.i, i64 4) ]
+  %5 = getelementptr inbounds %class.Loc.95, %class.Loc.95* %.0.i.i, i32 1
+  br label %2
+
+_ZSt8_DestroyIP3LocILi3EEEvT_S3_.exit:            ; preds = %2
+  ret void
+}
+
+declare void @llvm.assume(i1) #1
+
+attributes #0 = { "target-cpu"="x86-64" }
+attributes #1 = { willreturn readnone norecurse nocapture nofree }
Index: llvm/lib/Transforms/Scalar/LoopDeletion.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopDeletion.cpp
+++ llvm/lib/Transforms/Scalar/LoopDeletion.cpp
@@ -85,7 +85,9 @@
   // This includes instructions that could write to memory, and loads that are
   // marked volatile.
   for (auto &I : L->blocks())
-    if (any_of(*I, [](Instruction &I) { return I.mayHaveSideEffects(); }))
+    if (any_of(*I, [](Instruction &I) {
+          return I.mayHaveSideEffects() && !I.isDroppable();
+        }))
       return false;
   return true;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86816.294488.patch
Type: text/x-patch
Size: 2445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200926/3d516600/attachment.bin>


More information about the llvm-commits mailing list