llvm.org GIT mirror llvm / f914619
[LoopPassManager + MemorySSA] Only enable use of MemorySSA for LPMs known to preserve it. Summary: Add a flag to the FunctionToLoopAdaptor that allows enabling MemorySSA only for the loop pass managers that are known to preserve it. If an LPM is known to have only loop transforms that *all* preserve MemorySSA, then use MemorySSA if `EnableMSSALoopDependency` is set. If an LPM has loop passes that do not preserve MemorySSA, then the flag passed is `false`, regardless of the value of `EnableMSSALoopDependency`. When using a custom loop pass pipeline via `passes=...`, use keyword `loop` vs `loop-mssa` to use MemorySSA in that LPM. If a loop that does not preserve MemorySSA is added while using the `loop-mssa` keyword, that's an error. Add the new `loop-mssa` keyword to a few tests where a difference occurs when enabling MemorySSA. Reviewers: chandlerc Subscribers: mehdi_amini, Prazek, george.burgess.iv, sanjoy.google, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66376 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369548 91177308-0d34-0410-b5e6-96231b3b80d8 Alina Sbirlea 25 days ago
24 changed file(s) with 120 addition(s) and 52 deletion(s). Raw diff Collapse all Expand all
8585 template <> class LoopAnalysisManagerFunctionProxy::Result {
8686 public:
8787 explicit Result(LoopAnalysisManager &InnerAM, LoopInfo &LI)
88 : InnerAM(&InnerAM), LI(&LI) {}
89 Result(Result &&Arg) : InnerAM(std::move(Arg.InnerAM)), LI(Arg.LI) {
88 : InnerAM(&InnerAM), LI(&LI), MSSAUsed(false) {}
89 Result(Result &&Arg)
90 : InnerAM(std::move(Arg.InnerAM)), LI(Arg.LI), MSSAUsed(Arg.MSSAUsed) {
9091 // We have to null out the analysis manager in the moved-from state
9192 // because we are taking ownership of the responsibilty to clear the
9293 // analysis state.
9596 Result &operator=(Result &&RHS) {
9697 InnerAM = RHS.InnerAM;
9798 LI = RHS.LI;
99 MSSAUsed = RHS.MSSAUsed;
98100 // We have to null out the analysis manager in the moved-from state
99101 // because we are taking ownership of the responsibilty to clear the
100102 // analysis state.
110112 // didn't even see an invalidate call when we got invalidated.
111113 InnerAM->clear();
112114 }
115
116 /// Mark MemorySSA as used so we can invalidate self if MSSA is invalidated.
117 void markMSSAUsed() { MSSAUsed = true; }
113118
114119 /// Accessor for the analysis manager.
115120 LoopAnalysisManager &getManager() { return *InnerAM; }
129134 private:
130135 LoopAnalysisManager *InnerAM;
131136 LoopInfo *LI;
137 bool MSSAUsed;
132138 };
133139
134140 /// Provide a specialized run method for the \c LoopAnalysisManagerFunctionProxy
262262 class FunctionToLoopPassAdaptor
263263 : public PassInfoMixin> {
264264 public:
265 explicit FunctionToLoopPassAdaptor(LoopPassT Pass, bool DebugLogging = false)
266 : Pass(std::move(Pass)), LoopCanonicalizationFPM(DebugLogging) {
265 explicit FunctionToLoopPassAdaptor(LoopPassT Pass, bool UseMemorySSA = false,
266 bool DebugLogging = false)
267 : Pass(std::move(Pass)), LoopCanonicalizationFPM(DebugLogging),
268 UseMemorySSA(UseMemorySSA) {
267269 LoopCanonicalizationFPM.addPass(LoopSimplifyPass());
268270 LoopCanonicalizationFPM.addPass(LCSSAPass());
269271 }
292294 return PA;
293295
294296 // Get the analysis results needed by loop passes.
295 MemorySSA *MSSA = EnableMSSALoopDependency
297 MemorySSA *MSSA = UseMemorySSA
296298 ? (&AM.getResult(F).getMSSA())
297299 : nullptr;
298300 LoopStandardAnalysisResults LAR = {AM.getResult(F),
309311 // LoopStandardAnalysisResults object. The loop analyses cached in this
310312 // manager have access to those analysis results and so it must invalidate
311313 // itself when they go away.
312 LoopAnalysisManager &LAM =
313 AM.getResult(F).getManager();
314 auto &LAMFP = AM.getResult(F);
315 if (UseMemorySSA)
316 LAMFP.markMSSAUsed();
317 LoopAnalysisManager &LAM = LAMFP.getManager();
314318
315319 // A postorder worklist of loops to process.
316320 SmallPriorityWorklist Worklist;
381385 PA.preserve();
382386 PA.preserve();
383387 PA.preserve();
388 if (UseMemorySSA)
389 PA.preserve();
384390 // FIXME: What we really want to do here is preserve an AA category, but
385391 // that concept doesn't exist yet.
386392 PA.preserve();
394400 LoopPassT Pass;
395401
396402 FunctionPassManager LoopCanonicalizationFPM;
403
404 bool UseMemorySSA = false;
397405 };
398406
399407 /// A function to deduce a loop pass type and wrap it in the templated
400408 /// adaptor.
401409 template
402410 FunctionToLoopPassAdaptor
403 createFunctionToLoopPassAdaptor(LoopPassT Pass, bool DebugLogging = false) {
404 return FunctionToLoopPassAdaptor(std::move(Pass), DebugLogging);
411 createFunctionToLoopPassAdaptor(LoopPassT Pass, bool UseMemorySSA = false,
412 bool DebugLogging = false) {
413 return FunctionToLoopPassAdaptor(std::move(Pass), UseMemorySSA,
414 DebugLogging);
405415 }
406416
407417 /// Pass for printing a loop's contents as textual IR.
4545 // invalidation logic below to act on that.
4646 auto PAC = PA.getChecker();
4747 bool invalidateMemorySSAAnalysis = false;
48 if (EnableMSSALoopDependency)
48 if (MSSAUsed)
4949 invalidateMemorySSAAnalysis = Inv.invalidate(F, PA);
5050 if (!(PAC.preserved() || PAC.preservedSet>()) ||
5151 Inv.invalidate(F, PA) ||
476476 // We provide the opt remark emitter pass for LICM to use. We only need to do
477477 // this once as it is immutable.
478478 FPM.addPass(RequireAnalysisPass());
479 FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM1), DebugLogging));
479 FPM.addPass(createFunctionToLoopPassAdaptor(
480 std::move(LPM1), EnableMSSALoopDependency, DebugLogging));
480481 FPM.addPass(SimplifyCFGPass());
481482 FPM.addPass(InstCombinePass());
482 FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM2), DebugLogging));
483 // The loop passes in LPM2 (IndVarSimplifyPass, LoopIdiomRecognizePass,
484 // LoopDeletionPass and LoopFullUnrollPass) do not preserve MemorySSA.
485 // *All* loop passes must preserve it, in order to be able to use it.
486 FPM.addPass(createFunctionToLoopPassAdaptor(
487 std::move(LPM2), /*UseMemorySSA=*/false, DebugLogging));
483488
484489 // Eliminate redundancies.
485490 if (Level != O1) {
516521 FPM.addPass(DSEPass());
517522 FPM.addPass(createFunctionToLoopPassAdaptor(
518523 LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap),
519 DebugLogging));
524 EnableMSSALoopDependency, DebugLogging));
520525
521526 for (auto &C : ScalarOptimizerLateEPCallbacks)
522527 C(FPM, Level);
592597 MPM.addPass(PGOInstrumentationGen(IsCS));
593598
594599 FunctionPassManager FPM;
595 FPM.addPass(createFunctionToLoopPassAdaptor(LoopRotatePass(), DebugLogging));
600 FPM.addPass(createFunctionToLoopPassAdaptor(
601 LoopRotatePass(), EnableMSSALoopDependency, DebugLogging));
596602 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
597603
598604 // Add the profile lowering pass.
893899 C(OptimizePM, Level);
894900
895901 // First rotate loops that may have been un-rotated by prior passes.
896 OptimizePM.addPass(
897 createFunctionToLoopPassAdaptor(LoopRotatePass(), DebugLogging));
902 OptimizePM.addPass(createFunctionToLoopPassAdaptor(
903 LoopRotatePass(), EnableMSSALoopDependency, DebugLogging));
898904
899905 // Distribute loops to allow partial vectorization. I.e. isolate dependences
900906 // into separate loop that would otherwise inhibit vectorization. This is
953959 OptimizePM.addPass(RequireAnalysisPass());
954960 OptimizePM.addPass(createFunctionToLoopPassAdaptor(
955961 LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap),
956 DebugLogging));
962 EnableMSSALoopDependency, DebugLogging));
957963
958964 // Now that we've vectorized and unrolled loops, we may have more refined
959965 // alignment information, try to re-derive it here.
16611667 // Explicitly handle pass manager names.
16621668 if (Name == "function")
16631669 return true;
1664 if (Name == "loop")
1670 if (Name == "loop" || Name == "loop-mssa")
16651671 return true;
16661672
16671673 // Explicitly handle custom-parsed pass names.
16851691 template
16861692 static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks) {
16871693 // Explicitly handle pass manager names.
1688 if (Name == "loop")
1694 if (Name == "loop" || Name == "loop-mssa")
16891695 return true;
16901696
16911697 // Explicitly handle custom-parsed pass names.
19891995 FPM.addPass(std::move(NestedFPM));
19901996 return Error::success();
19911997 }
1992 if (Name == "loop") {
1998 if (Name == "loop" || Name == "loop-mssa") {
19931999 LoopPassManager LPM(DebugLogging);
19942000 if (auto Err = parseLoopPassPipeline(LPM, InnerPipeline, VerifyEachPass,
19952001 DebugLogging))
19962002 return Err;
19972003 // Add the nested pass manager with the appropriate adaptor.
1998 FPM.addPass(
1999 createFunctionToLoopPassAdaptor(std::move(LPM), DebugLogging));
2004 bool UseMemorySSA = (Name == "loop-mssa");
2005 FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM), UseMemorySSA,
2006 DebugLogging));
20002007 return Error::success();
20012008 }
20022009 if (auto Count = parseRepeatPassName(Name)) {
None ; Test that LICM uses basicaa to do alias analysis, which is capable of
0 ; Test that LICM uses basicaa to do alias analysis, which is capable of
11 ; disambiguating some obvious cases. If LICM is able to disambiguate the
22 ; two pointers, then the load should be hoisted, and the store sunk.
33
4 ; RUN: opt < %s -basicaa -licm -S | FileCheck %s
4 ; RUN: opt < %s -basicaa -licm -enable-mssa-loop-dependency=false -S | FileCheck %s -check-prefixes=CHECK,AST
5 ; RUN: opt < %s -basicaa -licm -enable-mssa-loop-dependency=true -S | FileCheck %s -check-prefixes=CHECK,MSSA
56 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
67
78 @A = global i32 7 ; [#uses=3]
2425 ; The Loop block should be empty after the load/store are promoted.
2526 ; CHECK: @test1
2627 ; CHECK: load i32, i32* @A
28 ; MSSA: load i32, i32* @A
29 ; MSSA: store i32 %Atmp, i32* @B
2730 ; CHECK: Loop:
2831 ; CHECK-NEXT: br i1 %c, label %Out, label %Loop
2932 ; CHECK: Out:
30 ; CHECK: store i32 %Atmp, i32* @B
33 ; AST: store i32 %Atmp, i32* @B
34 ; AST: load i32, i32* @A
3135 }
3236
3337 define i32 @test2(i1 %c) {
None ; RUN: opt -S -basicaa -licm -licm-n2-threshold=0 %s | FileCheck %s
0 ; RUN: opt -S -basicaa -licm -licm-n2-threshold=0 -enable-mssa-loop-dependency=false %s | FileCheck %s
1 ; RUN: opt -S -basicaa -licm -licm-n2-threshold=0 -enable-mssa-loop-dependency=true -verify-memoryssa %s | FileCheck %s --check-prefix=ALIAS-N2
12 ; RUN: opt -licm -basicaa -licm-n2-threshold=200 < %s -S | FileCheck %s --check-prefix=ALIAS-N2
3
24 ; RUN: opt -aa-pipeline=basic-aa -licm-n2-threshold=0 -passes='require,require,require,require,loop(licm)' < %s -S | FileCheck %s
5 ; RUN: opt -aa-pipeline=basic-aa -licm-n2-threshold=0 -passes='require,require,require,require,loop-mssa(licm)' < %s -S | FileCheck %s --check-prefix=ALIAS-N2
36 ; RUN: opt -aa-pipeline=basic-aa -licm-n2-threshold=200 -passes='require,require,require,require,loop(licm)' < %s -S | FileCheck %s --check-prefix=ALIAS-N2
4 ; RUN: opt -S -basicaa -licm -licm-n2-threshold=0 -enable-mssa-loop-dependency=true -verify-memoryssa %s | FileCheck %s --check-prefix=ALIAS-N2
57
68 declare i32 @foo() readonly argmemonly nounwind
79 declare i32 @foo2() readonly nounwind
None ; RUN: opt < %s -S -basicaa -licm | FileCheck %s
1 ; RUN: opt -aa-pipeline=basic-aa -passes='require,loop(licm)' < %s -S | FileCheck %s
0 ; RUN: opt < %s -S -basicaa -licm -enable-mssa-loop-dependency=false | FileCheck -check-prefixes=CHECK,AST %s
1 ; RUN: opt < %s -S -basicaa -licm -enable-mssa-loop-dependency=true | FileCheck -check-prefixes=CHECK,MSSA %s
2 ; RUN: opt -aa-pipeline=basic-aa -passes='require,loop(licm)' < %s -S | FileCheck -check-prefixes=CHECK,AST %s
3 ; RUN: opt -aa-pipeline=basic-aa -passes='require,loop-mssa(licm)' < %s -S | FileCheck -check-prefixes=CHECK,MSSA %s
24
35 ; Check that we can hoist unordered loads
46 define i32 @test1(i32* nocapture %y) nounwind uwtable ssp {
172174 end:
173175 ret i32 %vala
174176 ; CHECK-LABEL: define i32 @test7b(
175 ; CHECK-LABEL: entry:
176 ; CHECK: store i32 5, i32* %x
177 ; AST-LABEL: entry:
178 ; AST: store i32 5, i32* %x
177179 ; CHECK-LABEL: loop:
178180 ; CHECK: load atomic i32, i32* %y monotonic
179181 ; CHECK-LABEL: end:
182 ; MSSA: store i32 5, i32* %x
180183 ; CHECK: store atomic i32 %{{.+}}, i32* %z unordered, align 4
181184 }
182185
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
11 ; REQUIRES: asserts
2 ; RUN: opt -licm -basicaa -ipt-expensive-asserts=true < %s -S | FileCheck %s
2 ; RUN: opt -licm -basicaa -enable-mssa-loop-dependency=false -ipt-expensive-asserts=true < %s -S | FileCheck %s
3 ; RUN: opt -licm -basicaa -enable-mssa-loop-dependency=true -ipt-expensive-asserts=true < %s -S | FileCheck %s --check-prefixes=CHECK,MSSA
34 ; RUN: opt -aa-pipeline=basic-aa -passes='require,require,require,require,loop(licm)' -ipt-expensive-asserts=true < %s -S | FileCheck %s
5 ; RUN: opt -aa-pipeline=basic-aa -passes='require,require,require,require,loop-mssa(licm)' -ipt-expensive-asserts=true < %s -S | FileCheck %s --check-prefixes=CHECK,MSSA
46
57 ; Hoist guard and load.
68 define void @test1(i1 %cond, i32* %ptr) {
6062 ; CHECK-NEXT: br label [[LOOP:%.*]]
6163 ; CHECK: loop:
6264 ; CHECK-NEXT: [[X:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[X_INC:%.*]], [[LOOP]] ]
63 ; CHECK-NEXT: store i32 0, i32* [[P2]]
65 ; CHECK-NEXT: store i32 [[X]], i32* [[P2]]
6466 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[COND:%.*]]) [ "deopt"(i32 0) ]
6567 ; CHECK-NEXT: [[VAL:%.*]] = load i32, i32* [[PTR]]
6668 ; CHECK-NEXT: [[X_INC]] = add i32 [[X]], [[VAL]]
6769 ; CHECK-NEXT: br label [[LOOP]]
6870 ;
71
72 entry:
73 br label %loop
74
75 loop:
76 %x = phi i32 [ 0, %entry ], [ %x.inc, %loop ]
77 %p2 = getelementptr i32, i32* %ptr, i32 1
78 store i32 %x, i32* %p2
79 call void (i1, ...) @llvm.experimental.guard(i1 %cond) ["deopt" (i32 0)]
80 %val = load i32, i32* %ptr
81 %x.inc = add i32 %x, %val
82 br label %loop
83 }
84
85 ; But can hoist if the side effect is hoisted with MSSA
86 define void @test2b_prime(i1 %cond, i32* %ptr) {
87 ; MSSA-LABEL: @test2b_prime(
88 ; MSSA-NEXT: entry:
89 ; MSSA-NEXT: [[P2:%.*]] = getelementptr i32, i32* [[PTR:%.*]], i32 1
90 ; MSSA-NEXT: store i32 0, i32* [[P2]]
91 ; MSSA-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[COND:%.*]]) [ "deopt"(i32 0) ]
92 ; MSSA-NEXT: [[VAL:%.*]] = load i32, i32* [[PTR]]
93 ; MSSA-NEXT: br label [[LOOP:%.*]]
94 ; MSSA: loop:
95 ; MSSA-NEXT: [[X:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[X_INC:%.*]], [[LOOP]] ]
96 ; MSSA-NEXT: [[X_INC]] = add i32 [[X]], [[VAL]]
97 ; MSSA-NEXT: br label [[LOOP]]
6998
7099 entry:
71100 br label %loop
0 ; RUN: opt -S -basicaa -licm < %s | FileCheck %s
11 ; RUN: opt -aa-pipeline=basic-aa -passes='require,loop(simplify-cfg,licm)' -S < %s | FileCheck %s
22 ; RUN: opt -S -basicaa -licm -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s
3 ; RUN: opt -aa-pipeline=basic-aa -passes='require,loop(simplify-cfg,licm)' -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s
3 ; RUN: opt -aa-pipeline=basic-aa -passes='require,loop-mssa(simplify-cfg,licm)' -verify-memoryssa -S < %s | FileCheck %s
44
55 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
66 target triple = "x86_64-unknown-linux-gnu"
44 ; RUN: opt -passes='require,loop(licm)' -licm-control-flow-hoisting=1 -S < %s | FileCheck %s -check-prefixes=CHECK,CHECK-ENABLED
55 ; RUN: opt -passes='require,loop(licm)' -licm-control-flow-hoisting=0 -S < %s | FileCheck %s -check-prefixes=CHECK,CHECK-DISABLED
66
7 ; RUN: opt -passes='require,loop(licm)' -licm-control-flow-hoisting=1 -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s -check-prefixes=CHECK,CHECK-ENABLED
7 ; RUN: opt -passes='require,loop-mssa(licm)' -licm-control-flow-hoisting=1 -verify-memoryssa -S < %s | FileCheck %s -check-prefixes=CHECK,CHECK-ENABLED
88 ; Enable run below when adding promotion. e.g. "store i32 %phi, i32* %p" is promoted to phi.lcssa.
9 ; opt -passes='require,loop(licm)' -licm-control-flow-hoisting=0 -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s -check-prefixes=CHECK,CHECK-DISABLED
9 ; opt -passes='require,loop-mssa(licm)' -licm-control-flow-hoisting=0 -verify-memoryssa -S < %s | FileCheck %s -check-prefixes=CHECK,CHECK-DISABLED
1010
1111
1212 ; CHECK-LABEL: @triangle_phi
None ; RUN: opt -tbaa -basicaa -licm -S < %s | FileCheck %s
1 ; RUN: opt -aa-pipeline=type-based-aa,basic-aa -passes='require,require,require,require,loop(licm)' -S %s | FileCheck %s
0 ; RUN: opt -tbaa -basicaa -licm -enable-mssa-loop-dependency=false -S < %s | FileCheck %s --check-prefixes=CHECK,AST
1 ; RUN: opt -tbaa -basicaa -licm -enable-mssa-loop-dependency=true -S < %s | FileCheck %s --check-prefixes=CHECK,MSSA
2 ; RUN: opt -aa-pipeline=type-based-aa,basic-aa -passes='require,require,require,require,loop(licm)' -S %s | FileCheck %s --check-prefixes=CHECK,AST
3 ; RUN: opt -aa-pipeline=type-based-aa,basic-aa -passes='require,require,require,require,loop-mssa(licm)' -S %s | FileCheck %s --check-prefixes=CHECK,MSSA
24
35 ; LICM should keep the stores in their original order when it sinks/promotes them.
46 ; rdar://12045203
1113 define i32* @_Z4doiti(i32 %n, float* %tmp1, i32* %tmp3) nounwind {
1214 ; CHECK-LABEL: for.body.lr.ph:
1315 ; CHECK: store float 1.000000e+00, float* %tmp1
14 ; CHECK-LABEL: for.cond.for.end_crit_edge:
16 ; AST-LABEL: for.cond.for.end_crit_edge:
1517 ; CHECK: store i32 1, i32* %tmp3
18 ; MSSA-LABEL: for.cond.for.end_crit_edge:
1619
1720 entry:
1821 %cmp1 = icmp slt i32 0, %n
None ; RUN: opt -S -basicaa -licm -licm-n2-threshold=0 %s | FileCheck %s
0 ; RUN: opt -S -basicaa -licm -licm-n2-threshold=0 -enable-mssa-loop-dependency=false %s | FileCheck %s
1 ; RUN: opt -S -basicaa -licm -licm-n2-threshold=0 -enable-mssa-loop-dependency=true %s | FileCheck %s --check-prefix=ALIAS-N2
12 ; RUN: opt -licm -basicaa -licm-n2-threshold=200 < %s -S | FileCheck %s --check-prefix=ALIAS-N2
3
24 ; RUN: opt -aa-pipeline=basic-aa -licm-n2-threshold=0 -passes='require,require,require,require,loop(licm)' < %s -S | FileCheck %s
5 ; RUN: opt -aa-pipeline=basic-aa -licm-n2-threshold=0 -passes='require,require,require,require,loop-mssa(licm)' < %s -S | FileCheck %s --check-prefix=ALIAS-N2
36 ; RUN: opt -aa-pipeline=basic-aa -licm-n2-threshold=200 -passes='require,require,require,require,loop(licm)' < %s -S | FileCheck %s --check-prefix=ALIAS-N2
47
58 ; We should be able to hoist loads in presence of read only calls and stores
None ; RUN: opt -S -basicaa -licm %s | FileCheck -check-prefixes=CHECK,AST %s
0 ; RUN: opt -S -basicaa -licm -enable-mssa-loop-dependency=false %s | FileCheck -check-prefixes=CHECK,AST %s
11 ; RUN: opt -S -basicaa -licm -enable-mssa-loop-dependency=true %s | FileCheck -check-prefixes=CHECK,MSSA %s
22 ; RUN: opt -aa-pipeline=basic-aa -passes='require,require,require,require,loop(licm)' < %s -S | FileCheck -check-prefixes=CHECK,AST %s
3 ; RUN: opt -aa-pipeline=basic-aa -passes='require,require,require,require,loop-mssa(licm)' < %s -S | FileCheck -check-prefixes=CHECK,MSSA %s
34
45 define void @test(i32* %loc) {
56 ; CHECK-LABEL: @test
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
11 ; RUN: opt -S %s -passes=loop-instsimplify | FileCheck %s
2 ; RUN: opt -S %s -passes=loop-instsimplify -enable-mssa-loop-dependency=true -verify-memoryssa | FileCheck %s
2 ; RUN: opt -S %s -passes='loop-mssa(loop-instsimplify)' -verify-memoryssa | FileCheck %s
33
44 ; Test very basic folding and propagation occurs within a loop body. This should
55 ; collapse to the loop iteration structure and the LCSSA PHI node.
0 ; RUN: opt -S -loop-rotate < %s | FileCheck %s
11 ; RUN: opt -S -loop-rotate -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s
22 ; RUN: opt -S -passes='require,require,loop(rotate)' < %s | FileCheck %s
3 ; RUN: opt -S -passes='require,require,loop(rotate)' -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s
3 ; RUN: opt -S -passes='require,require,loop-mssa(rotate)' -verify-memoryssa < %s | FileCheck %s
44
55 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
66 target triple = "x86_64-apple-darwin10.0.0"
0 ;RUN: opt %s -passes='adce,loop(rotate),adce' -S -debug-pass-manager -debug-only=loop-rotate 2>&1 | FileCheck %s
1 ;RUN: opt %s -passes='adce,loop(rotate),adce' -S -debug-pass-manager -debug-only=loop-rotate -enable-mssa-loop-dependency=true -verify-memoryssa 2>&1 | FileCheck %s --check-prefix=MSSA
1 ;RUN: opt %s -passes='adce,loop-mssa(rotate),adce' -S -debug-pass-manager -debug-only=loop-rotate -verify-memoryssa 2>&1 | FileCheck %s --check-prefix=MSSA
22 ;REQUIRES: asserts
33
44 ; This test is to make sure we invalidate the post dominator pass after loop rotate simplifies the loop latch.
0 ; RUN: opt -passes='loop(unswitch),verify' -S < %s | FileCheck %s
1 ; RUN: opt -enable-mssa-loop-dependency=true -verify-memoryssa -passes='loop(unswitch),verify' -S < %s | FileCheck %s
1 ; RUN: opt -verify-memoryssa -passes='loop-mssa(unswitch),verify' -S < %s | FileCheck %s
22
33 declare void @incf()
44 declare void @decf()
0 ; RUN: opt -passes='loop(unswitch),verify' -S < %s | FileCheck %s
1 ; RUN: opt -enable-mssa-loop-dependency=true -verify-memoryssa -passes='loop(unswitch),verify' -S < %s | FileCheck %s
1 ; RUN: opt -verify-memoryssa -passes='loop-mssa(unswitch),verify' -S < %s | FileCheck %s
22
33 define i32 @test(i32* %A, i1 %C) {
44 entry:
0 ; RUN: opt -passes='loop(unswitch),verify' -simple-loop-unswitch-guards -S < %s | FileCheck %s
11 ; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -simple-loop-unswitch-guards -S < %s | FileCheck %s
2 ; RUN: opt -passes='loop(unswitch),verify' -simple-loop-unswitch-guards -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s
2 ; RUN: opt -passes='loop-mssa(unswitch),verify' -simple-loop-unswitch-guards -verify-memoryssa -S < %s | FileCheck %s
33
44 declare void @llvm.experimental.guard(i1, ...)
55
0 ; RUN: opt -passes='loop(unswitch),verify' -S < %s | FileCheck %s
1 ; RUN: opt -enable-mssa-loop-dependency=true -verify-memoryssa -passes='loop(unswitch),verify' -S < %s | FileCheck %s
1 ; RUN: opt -verify-memoryssa -passes='loop-mssa(unswitch),verify' -S < %s | FileCheck %s
22
33 declare void @unknown()
44 declare void @unknown2()
0 ; RUN: opt -passes='loop(loop-instsimplify,simplify-cfg,unswitch),verify' -S < %s | FileCheck %s
1 ; RUN: opt -enable-mssa-loop-dependency=true -verify-memoryssa -passes='loop(loop-instsimplify,simplify-cfg,unswitch),verify' -S < %s | FileCheck %s
1 ; RUN: opt -verify-memoryssa -passes='loop-mssa(loop-instsimplify,simplify-cfg,unswitch),verify' -S < %s | FileCheck %s
22
33 declare void @some_func() noreturn
44
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
11 ; then metadata checks MDn were added manually.
22 ; RUN: opt -passes='loop(unswitch),verify' -S < %s | FileCheck %s
3 ; RUN: opt -enable-mssa-loop-dependency=true -verify-memoryssa -passes='loop(unswitch),verify' -S < %s | FileCheck %s
3 ; RUN: opt -verify-memoryssa -passes='loop-mssa(unswitch),verify' -S < %s | FileCheck %s
44
55 declare void @some_func()
66
0 ; RUN: opt -passes='loop(unswitch),verify' -S < %s | FileCheck %s
1 ; RUN: opt -enable-mssa-loop-dependency=true -verify-memoryssa -passes='loop(unswitch),verify' -S < %s | FileCheck %s
1 ; RUN: opt -verify-memoryssa -passes='loop-mssa(unswitch),verify' -S < %s | FileCheck %s
22
33 declare void @some_func() noreturn
44 declare void @sink(i32)
0 ; RUN: opt -passes='print,loop(unswitch,loop-instsimplify),print' -S < %s 2>%t.scev | FileCheck %s
1 ; RUN: opt -enable-mssa-loop-dependency=true -verify-memoryssa -passes='print,loop(unswitch,loop-instsimplify),print' -S < %s 2>%t.scev | FileCheck %s
1 ; RUN: opt -verify-memoryssa -passes='print,loop-mssa(unswitch,loop-instsimplify),print' -S < %s 2>%t.scev | FileCheck %s
22 ; RUN: FileCheck %s --check-prefix=SCEV < %t.scev
33
44 target triple = "x86_64-unknown-linux-gnu"