[PATCH] D51181: [LICM] Hoist an invariant_start out of loops if there are no stores executed before it

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 24 09:25:48 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL340617: [LICM] Hoist an invariant_start out of loops if there are no stores executed… (authored by reames, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51181?vs=162259&id=162394#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51181

Files:
  llvm/trunk/lib/Transforms/Scalar/LICM.cpp
  llvm/trunk/test/Transforms/LICM/invariant.start.ll


Index: llvm/trunk/test/Transforms/LICM/invariant.start.ll
===================================================================
--- llvm/trunk/test/Transforms/LICM/invariant.start.ll
+++ llvm/trunk/test/Transforms/LICM/invariant.start.ll
@@ -3,19 +3,18 @@
 ; RUN: opt -aa-pipeline=basic-aa -licm-n2-threshold=0 -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' < %s -S | FileCheck %s
 ; RUN: opt -aa-pipeline=basic-aa -licm-n2-threshold=200 -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' < %s -S | FileCheck %s --check-prefix=ALIAS-N2
 
-; TODO: By default (without the -licm-n2-threshold value), we should be able to hoist both load and invariant.start
 define void @test1(i1 %cond, i32* %ptr) {
 ; CHECK-LABEL: @test1(
 ; CHECK-LABEL: entry:
+; CHECK: call {}* @llvm.invariant.start.p0i32(i64 4, i32* %ptr)
 ; CHECK: %val = load i32, i32* %ptr
 ; CHECK-LABEL: loop:
-; CHECK: call {}* @llvm.invariant.start.p0i32(i64 4, i32* %ptr)
 
 ; ALIAS-N2-LABEL: @test1(
 ; ALIAS-N2-LABEL: entry:
-; ALIAS-N2:         %val = load i32, i32* %ptr
-; ALIAS-N2-LABEL: loop:
 ; ALIAS-N2: call {}* @llvm.invariant.start.p0i32(i64 4, i32* %ptr)
+; ALIAS-N2: %val = load i32, i32* %ptr
+; ALIAS-N2-LABEL: loop:
 
 entry:
   br label %loop
@@ -57,15 +56,15 @@
 define void @test3(i1 %cond, i32* %ptr) {
 ; CHECK-LABEL: @test3(
 ; CHECK-LABEL: entry:
+; CHECK: call {}* @llvm.invariant.start.p0i32(i64 4, i32* %ptr)
 ; CHECK: %val = load i32, i32* %ptr
 ; CHECK-LABEL: loop:
-; CHECK: call {}* @llvm.invariant.start.p0i32(i64 4, i32* %ptr)
 
 ; ALIAS-N2-LABEL: @test3(
 ; ALIAS-N2-LABEL: entry:
-; ALIAS-N2:         %val = load i32, i32* %ptr
+; ALIAS-N2: call {}* @llvm.invariant.start.p0i32(i64 4, i32* %ptr)
+; ALIAS-N2: %val = load i32, i32* %ptr
 ; ALIAS-N2-LABEL: loop:
-; ALIAS-N2:         call {}* @llvm.invariant.start.p0i32(i64 4, i32* %ptr)
 entry:
   br label %loop
 
Index: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp
@@ -525,7 +525,9 @@
       }
 
       using namespace PatternMatch;
-      if (match(&I, m_Intrinsic<Intrinsic::experimental_guard>()) &&
+      if (((I.use_empty() &&
+            match(&I, m_Intrinsic<Intrinsic::invariant_start>())) ||
+           match(&I, m_Intrinsic<Intrinsic::experimental_guard>())) &&
           IsMustExecute && IsMemoryNotModified &&
           CurLoop->hasLoopInvariantOperands(&I)) {
         hoist(I, DT, CurLoop, SafetyInfo, ORE);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51181.162394.patch
Type: text/x-patch
Size: 2637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180824/d8952bf5/attachment.bin>


More information about the llvm-commits mailing list