diff options
author | Alina Sbirlea <asbirlea@google.com> | 2019-01-10 19:29:04 +0000 |
---|---|---|
committer | Alina Sbirlea <asbirlea@google.com> | 2019-01-10 19:29:04 +0000 |
commit | cae12edaaa34b03cde173d5ae7f81780d2ae01af (patch) | |
tree | 8b196870b28ac4680a97e28f0bb995150af129d2 /llvm/test/Transforms/LICM | |
parent | 54c04301b794319cec16161dba30c44858ababb3 (diff) | |
download | bcm5719-llvm-cae12edaaa34b03cde173d5ae7f81780d2ae01af.tar.gz bcm5719-llvm-cae12edaaa34b03cde173d5ae7f81780d2ae01af.zip |
Use MemorySSA in LICM to do sinking and hoisting.
Summary:
Step 2 in using MemorySSA in LICM:
Use MemorySSA in LICM to do sinking and hoisting, all under "EnableMSSALoopDependency" flag.
Promotion is disabled.
Enable flag in LICM sink/hoist tests to test correctness of this change. Moved one test which
relied on promotion, in order to test all sinking tests.
Reviewers: sanjoy, davide, gberry, george.burgess.iv
Subscribers: llvm-commits, Prazek
Differential Revision: https://reviews.llvm.org/D40375
llvm-svn: 350879
Diffstat (limited to 'llvm/test/Transforms/LICM')
-rw-r--r-- | llvm/test/Transforms/LICM/argmemonly-call.ll | 25 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/hoist-bitcast-load.ll | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/hoist-debuginvariant.ll | 3 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/hoist-deref-load.ll | 2 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/hoist-fast-fdiv.ll | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/hoist-invariant-load.ll | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/hoist-nounwind.ll | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/hoist-phi.ll | 5 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/hoist-round.ll | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/hoisting.ll | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/sink-promote.ll | 50 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/sink.ll | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/sinking.ll | 47 | ||||
-rw-r--r-- | llvm/test/Transforms/LICM/volatile-alias.ll | 1 |
14 files changed, 96 insertions, 44 deletions
diff --git a/llvm/test/Transforms/LICM/argmemonly-call.ll b/llvm/test/Transforms/LICM/argmemonly-call.ll index b9e0818e80b..86c92a558fd 100644 --- a/llvm/test/Transforms/LICM/argmemonly-call.ll +++ b/llvm/test/Transforms/LICM/argmemonly-call.ll @@ -2,6 +2,7 @@ ; RUN: opt -licm -basicaa -licm-n2-threshold=200 < %s -S | FileCheck %s --check-prefix=ALIAS-N2 ; 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 +; RUN: opt -S -basicaa -licm -licm-n2-threshold=0 -enable-mssa-loop-dependency=true -verify-memoryssa %s | FileCheck %s --check-prefix=ALIAS-N2 declare i32 @foo() readonly argmemonly nounwind declare i32 @foo2() readonly nounwind @@ -11,6 +12,9 @@ define void @test(i32* %loc) { ; CHECK-LABEL: @test ; CHECK: @foo ; CHECK-LABEL: loop: +; ALIAS-N2-LABEL: @test +; ALIAS-N2: @foo +; ALIAS-N2-LABEL: loop: br label %loop loop: @@ -24,6 +28,9 @@ define void @test_neg(i32* %loc) { ; CHECK-LABEL: @test_neg ; CHECK-LABEL: loop: ; CHECK: @foo +; ALIAS-N2-LABEL: @test_neg +; ALIAS-N2-LABEL: loop: +; ALIAS-N2: @foo br label %loop loop: @@ -36,6 +43,9 @@ define void @test2(i32* noalias %loc, i32* noalias %loc2) { ; CHECK-LABEL: @test2 ; CHECK: @bar ; CHECK-LABEL: loop: +; ALIAS-N2-LABEL: @test2 +; ALIAS-N2: @bar +; ALIAS-N2-LABEL: loop: br label %loop loop: @@ -49,6 +59,9 @@ define void @test3(i32* %loc) { ; CHECK-LABEL: @test3 ; CHECK-LABEL: loop: ; CHECK: @bar +; ALIAS-N2-LABEL: @test3 +; ALIAS-N2-LABEL: loop: +; ALIAS-N2: @bar br label %loop loop: @@ -64,6 +77,9 @@ define void @test4(i32* %loc, i32* %loc2) { ; CHECK-LABEL: @test4 ; CHECK-LABEL: loop: ; CHECK: @bar +; ALIAS-N2-LABEL: @test4 +; ALIAS-N2-LABEL: loop: +; ALIAS-N2: @bar br label %loop loop: @@ -77,6 +93,7 @@ declare i32 @foo_new(i32*) readonly ; we clump foo_new with bar. ; With the N2 Alias analysis diagnostic tool, we are able to hoist the ; argmemonly bar call out of the loop. +; Using MemorySSA we can also hoist bar. define void @test5(i32* %loc2, i32* noalias %loc) { ; ALIAS-N2-LABEL: @test5 @@ -103,6 +120,10 @@ define void @test6(i32* noalias %loc, i32* noalias %loc2) { ; CHECK: %val = load i32, i32* %loc2 ; CHECK-LABEL: loop: ; CHECK: @llvm.memcpy +; ALIAS-N2-LABEL: @test6 +; ALIAS-N2: %val = load i32, i32* %loc2 +; ALIAS-N2-LABEL: loop: +; ALIAS-N2: @llvm.memcpy br label %loop loop: @@ -119,6 +140,10 @@ define void @test7(i32* noalias %loc, i32* noalias %loc2) { ; CHECK: %val = load i32, i32* %loc2 ; CHECK-LABEL: loop: ; CHECK: @custom_memcpy +; ALIAS-N2-LABEL: @test7 +; ALIAS-N2: %val = load i32, i32* %loc2 +; ALIAS-N2-LABEL: loop: +; ALIAS-N2: @custom_memcpy br label %loop loop: diff --git a/llvm/test/Transforms/LICM/hoist-bitcast-load.ll b/llvm/test/Transforms/LICM/hoist-bitcast-load.ll index 956c7283be3..fcd6d08f2b4 100644 --- a/llvm/test/Transforms/LICM/hoist-bitcast-load.ll +++ b/llvm/test/Transforms/LICM/hoist-bitcast-load.ll @@ -1,5 +1,6 @@ ; RUN: opt -S -basicaa -licm < %s | FileCheck %s ; RUN: opt -aa-pipeline=basic-aa -passes='require<opt-remark-emit>,loop(simplify-cfg,licm)' -S < %s | FileCheck %s +; RUN: opt -S -basicaa -licm -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/llvm/test/Transforms/LICM/hoist-debuginvariant.ll b/llvm/test/Transforms/LICM/hoist-debuginvariant.ll index 95c4018e46c..71aeb7549ce 100644 --- a/llvm/test/Transforms/LICM/hoist-debuginvariant.ll +++ b/llvm/test/Transforms/LICM/hoist-debuginvariant.ll @@ -1,5 +1,6 @@ ; RUN: opt < %s -licm -S | FileCheck %s ; RUN: opt < %s -strip-debug -licm -S | FileCheck %s +; RUN: opt < %s -licm -enable-mssa-loop-dependency=true -verify-memoryssa -S | FileCheck %s --check-prefixes=CHECK,MSSA target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -16,7 +17,9 @@ define void @fn1() !dbg !6 { ; CHECK-NEXT: [[_TMP2:%.*]] = load i32, i32* @a, align 4 ; CHECK-NEXT: [[_TMP3:%.*]] = load i32, i32* @b, align 4 ; CHECK-NEXT: [[_TMP4:%.*]] = sdiv i32 [[_TMP2]], [[_TMP3]] +; MSSA-NEXT: store i32 [[_TMP4:%.*]], i32* @c, align 4 ; CHECK-NEXT: br label [[BB3:%.*]] + br label %bb3 bb3: ; preds = %bb3, %0 diff --git a/llvm/test/Transforms/LICM/hoist-deref-load.ll b/llvm/test/Transforms/LICM/hoist-deref-load.ll index 6c9a8177408..aacff88ac12 100644 --- a/llvm/test/Transforms/LICM/hoist-deref-load.ll +++ b/llvm/test/Transforms/LICM/hoist-deref-load.ll @@ -1,5 +1,7 @@ ; RUN: opt -S -basicaa -licm < %s | FileCheck %s ; RUN: opt -aa-pipeline=basic-aa -passes='require<opt-remark-emit>,loop(simplify-cfg,licm)' -S < %s | FileCheck %s +; RUN: opt -S -basicaa -licm -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s +; RUN: opt -aa-pipeline=basic-aa -passes='require<opt-remark-emit>,loop(simplify-cfg,licm)' -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/llvm/test/Transforms/LICM/hoist-fast-fdiv.ll b/llvm/test/Transforms/LICM/hoist-fast-fdiv.ll index 57df241a2ce..bdefcf9e8f4 100644 --- a/llvm/test/Transforms/LICM/hoist-fast-fdiv.ll +++ b/llvm/test/Transforms/LICM/hoist-fast-fdiv.ll @@ -1,4 +1,5 @@ ; RUN: opt -licm -S < %s | FileCheck %s +; RUN: opt -licm -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s ; Function Attrs: noinline norecurse nounwind readnone ssp uwtable define zeroext i1 @invariant_denom(double %v) #0 { diff --git a/llvm/test/Transforms/LICM/hoist-invariant-load.ll b/llvm/test/Transforms/LICM/hoist-invariant-load.ll index ed669f383fc..909652b8f46 100644 --- a/llvm/test/Transforms/LICM/hoist-invariant-load.ll +++ b/llvm/test/Transforms/LICM/hoist-invariant-load.ll @@ -1,5 +1,6 @@ ; REQUIRES: asserts ; RUN: opt < %s -licm -disable-basicaa -stats -S 2>&1 | grep "1 licm" +; RUN: opt < %s -licm -enable-mssa-loop-dependency=true -verify-memoryssa -disable-basicaa -stats -S 2>&1 | grep "1 licm" @"\01L_OBJC_METH_VAR_NAME_" = internal global [4 x i8] c"foo\00", section "__TEXT,__objc_methname,cstring_literals", align 1 @"\01L_OBJC_SELECTOR_REFERENCES_" = internal global i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"\01L_OBJC_METH_VAR_NAME_", i32 0, i32 0), section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip" diff --git a/llvm/test/Transforms/LICM/hoist-nounwind.ll b/llvm/test/Transforms/LICM/hoist-nounwind.ll index d53e4043af1..a582173a156 100644 --- a/llvm/test/Transforms/LICM/hoist-nounwind.ll +++ b/llvm/test/Transforms/LICM/hoist-nounwind.ll @@ -1,5 +1,6 @@ ; RUN: opt -S -basicaa -licm < %s | FileCheck %s ; RUN: opt -aa-pipeline=basic-aa -passes='require<opt-remark-emit>,loop(licm)' -S %s | FileCheck %s +; RUN: opt -S -basicaa -licm -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/llvm/test/Transforms/LICM/hoist-phi.ll b/llvm/test/Transforms/LICM/hoist-phi.ll index a7111560e60..f3a137db5f3 100644 --- a/llvm/test/Transforms/LICM/hoist-phi.ll +++ b/llvm/test/Transforms/LICM/hoist-phi.ll @@ -5,6 +5,11 @@ ; RUN: opt -passes='require<opt-remark-emit>,loop(licm)' -licm-control-flow-hoisting=1 -S < %s | FileCheck %s -check-prefixes=CHECK,CHECK-ENABLED ; RUN: opt -passes='require<opt-remark-emit>,loop(licm)' -licm-control-flow-hoisting=0 -S < %s | FileCheck %s -check-prefixes=CHECK,CHECK-DISABLED +; RUN: opt -passes='require<opt-remark-emit>,loop(licm)' -licm-control-flow-hoisting=1 -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s -check-prefixes=CHECK,CHECK-ENABLED +; Enable run below when adding promotion. e.g. "store i32 %phi, i32* %p" is promoted to phi.lcssa. +; opt -passes='require<opt-remark-emit>,loop(licm)' -licm-control-flow-hoisting=0 -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s -check-prefixes=CHECK,CHECK-DISABLED + + ; CHECK-LABEL: @triangle_phi define void @triangle_phi(i32 %x, i32* %p) { ; CHECK-LABEL: entry: diff --git a/llvm/test/Transforms/LICM/hoist-round.ll b/llvm/test/Transforms/LICM/hoist-round.ll index 35851f39d25..10f75be4d32 100644 --- a/llvm/test/Transforms/LICM/hoist-round.ll +++ b/llvm/test/Transforms/LICM/hoist-round.ll @@ -1,5 +1,6 @@ ; RUN: opt -S -licm < %s | FileCheck %s ; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' -S %s | FileCheck %s +; RUN: opt -S -licm -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s target datalayout = "E-m:e-p:32:32-i8:8:8-i16:16:16-i64:32:32-f64:32:32-v64:32:32-v128:32:32-a0:0:32-n32" diff --git a/llvm/test/Transforms/LICM/hoisting.ll b/llvm/test/Transforms/LICM/hoisting.ll index 4572ad38d3c..f65b965d555 100644 --- a/llvm/test/Transforms/LICM/hoisting.ll +++ b/llvm/test/Transforms/LICM/hoisting.ll @@ -1,5 +1,6 @@ ; RUN: opt < %s -licm -S | FileCheck %s ; RUN: opt < %s -aa-pipeline=basic-aa -passes='require<opt-remark-emit>,loop(licm)' -S | FileCheck %s +; RUN: opt < %s -licm -enable-mssa-loop-dependency=true -verify-memoryssa -S | FileCheck %s @X = global i32 0 ; <i32*> [#uses=1] diff --git a/llvm/test/Transforms/LICM/sink-promote.ll b/llvm/test/Transforms/LICM/sink-promote.ll new file mode 100644 index 00000000000..45024c46da9 --- /dev/null +++ b/llvm/test/Transforms/LICM/sink-promote.ll @@ -0,0 +1,50 @@ +; RUN: opt < %s -basicaa -licm -S | FileCheck %s + +; Test moved from sinking.ll, as it tests sinking of a store who alone touches +; a memory location in a loop. +; Store can be sunk out of exit block containing indirectbr instructions after +; D50925. Updated to use an argument instead of undef, due to PR38989. +define void @test12(i32* %ptr) { +; CHECK-LABEL: @test12 +; CHECK: store +; CHECK-NEXT: br label %lab4 + br label %lab4 + +lab4: + br label %lab20 + +lab5: + br label %lab20 + +lab6: + br label %lab4 + +lab7: + br i1 undef, label %lab8, label %lab13 + +lab8: + br i1 undef, label %lab13, label %lab10 + +lab10: + br label %lab7 + +lab13: + ret void + +lab20: + br label %lab21 + +lab21: +; CHECK: lab21: +; CHECK-NOT: store +; CHECK: br i1 false, label %lab21, label %lab22 + store i32 36127957, i32* %ptr, align 4 + br i1 undef, label %lab21, label %lab22 + +lab22: +; CHECK: lab22: +; CHECK-NOT: store +; CHECK-NEXT: indirectbr i8* undef + indirectbr i8* undef, [label %lab5, label %lab6, label %lab7] +} + diff --git a/llvm/test/Transforms/LICM/sink.ll b/llvm/test/Transforms/LICM/sink.ll index 70fa6fa13e3..17170f5af19 100644 --- a/llvm/test/Transforms/LICM/sink.ll +++ b/llvm/test/Transforms/LICM/sink.ll @@ -2,6 +2,7 @@ ; RUN: opt -S -licm < %s | opt -S -loop-sink | FileCheck %s --check-prefix=CHECK-SINK ; RUN: opt -S < %s -passes='require<opt-remark-emit>,loop(licm),loop-sink' \ ; RUN: | FileCheck %s --check-prefix=CHECK-SINK +; RUN: opt -S -licm -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s --check-prefix=CHECK-LICM ; Original source code: ; int g; diff --git a/llvm/test/Transforms/LICM/sinking.ll b/llvm/test/Transforms/LICM/sinking.ll index 3bcbc5d67db..cc30494a518 100644 --- a/llvm/test/Transforms/LICM/sinking.ll +++ b/llvm/test/Transforms/LICM/sinking.ll @@ -1,5 +1,7 @@ ; RUN: opt < %s -basicaa -licm -S | FileCheck %s ; RUN: opt < %s -debugify -basicaa -licm -S | FileCheck %s -check-prefix=DEBUGIFY +; RUN: opt < %s -basicaa -licm -S -enable-mssa-loop-dependency=true -verify-memoryssa | FileCheck %s + declare i32 @strlen(i8*) readonly nounwind @@ -358,50 +360,7 @@ exit: ret i32 %lcssa } -; Can't sink stores out of exit blocks containing indirectbr instructions -; because loop simplify does not create dedicated exits for such blocks. Test -; that by sinking the store from lab21 to lab22, but not further. -define void @test12() { -; CHECK-LABEL: @test12 - br label %lab4 - -lab4: - br label %lab20 - -lab5: - br label %lab20 - -lab6: - br label %lab4 - -lab7: - br i1 undef, label %lab8, label %lab13 - -lab8: - br i1 undef, label %lab13, label %lab10 - -lab10: - br label %lab7 - -lab13: - ret void - -lab20: - br label %lab21 - -lab21: -; CHECK: lab21: -; CHECK-NOT: store -; CHECK: br i1 false, label %lab21, label %lab22 - store i32 36127957, i32* undef, align 4 - br i1 undef, label %lab21, label %lab22 - -lab22: -; CHECK: lab22: -; CHECK: store -; CHECK-NEXT: indirectbr i8* undef - indirectbr i8* undef, [label %lab5, label %lab6, label %lab7] -} +; @test12 moved to sink-promote.ll, as it tests sinking and promotion. ; Test that we don't crash when trying to sink stores and there's no preheader ; available (which is used for creating loads that may be used by the SSA diff --git a/llvm/test/Transforms/LICM/volatile-alias.ll b/llvm/test/Transforms/LICM/volatile-alias.ll index f387012015c..c1f727c4e38 100644 --- a/llvm/test/Transforms/LICM/volatile-alias.ll +++ b/llvm/test/Transforms/LICM/volatile-alias.ll @@ -1,5 +1,6 @@ ; RUN: opt -basicaa -sroa -loop-rotate -licm -S < %s | FileCheck %s ; RUN: opt -basicaa -sroa -loop-rotate %s | opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' -S | FileCheck %s +; RUN: opt -basicaa -sroa -loop-rotate -licm -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s ; The objects *p and *q are aliased to each other, but even though *q is ; volatile, *p can be considered invariant in the loop. Check if it is moved ; out of the loop. |