Index: lib/Analysis/MemorySSA.cpp =================================================================== --- lib/Analysis/MemorySSA.cpp +++ lib/Analysis/MemorySSA.cpp @@ -84,7 +84,7 @@ #endif /// Enables memory ssa as a dependency for loop passes in legacy pass manager. cl::opt llvm::EnableMSSALoopDependency( - "enable-mssa-loop-dependency", cl::Hidden, cl::init(false), + "enable-mssa-loop-dependency", cl::Hidden, cl::init(true), cl::desc("Enable MemorySSA dependency for loop pass manager")); static cl::opt Index: lib/Transforms/Utils/LoopUtils.cpp =================================================================== --- lib/Transforms/Utils/LoopUtils.cpp +++ lib/Transforms/Utils/LoopUtils.cpp @@ -19,6 +19,7 @@ #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopPass.h" +#include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/MemorySSAUpdater.h" #include "llvm/Analysis/MustExecute.h" #include "llvm/Analysis/ScalarEvolution.h" @@ -169,6 +170,12 @@ AU.addPreserved(); AU.addRequired(); AU.addPreserved(); + // FIXME: enable when all loop passes preserve MemorySSA. + // Remove individual handling in each pass when that happens. + if (false) { + AU.addRequired(); + AU.addPreserved(); + } } /// Manually defined generic "LoopPass" dependency initialization. This is used @@ -189,6 +196,7 @@ INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass) INITIALIZE_PASS_DEPENDENCY(SCEVAAWrapperPass) INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass) + INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass) } /// Create MDNode for input string. Index: test/Analysis/BasicAA/store-promote.ll =================================================================== --- test/Analysis/BasicAA/store-promote.ll +++ test/Analysis/BasicAA/store-promote.ll @@ -2,7 +2,8 @@ ; disambiguating some obvious cases. If LICM is able to disambiguate the ; two pointers, then the load should be hoisted, and the store sunk. -; RUN: opt < %s -basicaa -licm -S | FileCheck %s +; RUN: opt < %s -basicaa -licm -enable-mssa-loop-dependency=false -S | FileCheck %s -check-prefixes=CHECK,AST +; RUN: opt < %s -basicaa -licm -enable-mssa-loop-dependency=true -S | FileCheck %s -check-prefixes=CHECK,MSSA 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" @A = global i32 7 ; [#uses=3] @@ -25,10 +26,13 @@ ; The Loop block should be empty after the load/store are promoted. ; CHECK: @test1 ; CHECK: load i32, i32* @A +; MSSA: load i32, i32* @A +; MSSA: store i32 %Atmp, i32* @B ; CHECK: Loop: ; CHECK-NEXT: br i1 %c, label %Out, label %Loop ; CHECK: Out: -; CHECK: store i32 %Atmp, i32* @B +; AST: store i32 %Atmp, i32* @B +; AST: load i32, i32* @A } define i32 @test2(i1 %c) { Index: test/CodeGen/PowerPC/sms-grp-order.ll =================================================================== --- test/CodeGen/PowerPC/sms-grp-order.ll +++ test/CodeGen/PowerPC/sms-grp-order.ll @@ -4,25 +4,24 @@ define void @lame_encode_buffer_interleaved() local_unnamed_addr { ; CHECK-LABEL: lame_encode_buffer_interleaved: -; CHECK: # %bb.0: -; CHECK-NEXT: lhz 3, 0(0) -; CHECK-NEXT: li 5, 1 -; CHECK-NEXT: sldi 5, 5, 62 -; CHECK-NEXT: lhz 4, 0(3) -; CHECK-NEXT: mtctr 5 -; CHECK-NEXT: .p2align 5 -; CHECK-NEXT: .LBB0_1: # -; CHECK-NEXT: extsh 3, 3 -; CHECK-NEXT: extsh 4, 4 -; CHECK-NEXT: srawi 3, 3, 1 -; CHECK-NEXT: addze 3, 3 -; CHECK-NEXT: srawi 4, 4, 1 -; CHECK-NEXT: addze 4, 4 -; CHECK-NEXT: bdnz .LBB0_1 -; CHECK-NEXT: # %bb.2: -; CHECK-NEXT: sth 3, 0(0) -; CHECK-NEXT: sth 4, 0(3) -; CHECK-NEXT: blr +; CHECK: # %bb.0: +; CHECK-NEXT: lha 3, 0(3) +; CHECK-NEXT: li 5, 1 +; CHECK-NEXT: sldi 5, 5, 62 +; CHECK-NEXT: lhz 4, 0(0) +; CHECK-NEXT: mtctr 5 +; CHECK-NEXT: srawi 3, 3, 1 +; CHECK-NEXT: addze 3, 3 +; CHECK-NEXT: .p2align 4 +; CHECK-NEXT: .LBB0_1: +; CHECK-NEXT: extsh 4, 4 +; CHECK-NEXT: srawi 4, 4, 1 +; CHECK-NEXT: addze 4, 4 +; CHECK-NEXT: bdnz .LBB0_1 +; CHECK-NEXT: # %bb.2: +; CHECK-NEXT: sth 4, 0(0) +; CHECK-NEXT: sth 3, 0(3) +; CHECK-NEXT: blr br label %1 1: ; preds = %1, %0 Index: test/Other/loop-pm-invalidation.ll =================================================================== --- test/Other/loop-pm-invalidation.ll +++ test/Other/loop-pm-invalidation.ll @@ -67,6 +67,7 @@ ; CHECK-LOOP-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-LOOP-INV-NEXT: Running pass: LCSSAPass ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-LOOP-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: AAManager ; CHECK-LOOP-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -104,6 +105,7 @@ ; CHECK-SCEV-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-SCEV-INV-NEXT: Running pass: LCSSAPass ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-SCEV-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: AAManager ; CHECK-SCEV-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -151,6 +153,7 @@ ; CHECK-LOOP-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-LOOP-INV-NEXT: Running pass: LCSSAPass ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-LOOP-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: AAManager ; CHECK-LOOP-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -197,6 +200,7 @@ ; CHECK-SCEV-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-SCEV-INV-NEXT: Running pass: LCSSAPass ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-SCEV-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: AAManager ; CHECK-SCEV-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -260,6 +264,7 @@ ; CHECK-LOOP-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-LOOP-INV-NEXT: Running pass: LCSSAPass ; CHECK-LOOP-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-LOOP-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: AAManager ; CHECK-LOOP-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-LOOP-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -297,6 +302,7 @@ ; CHECK-SCEV-INV-NEXT: Running analysis: AssumptionAnalysis ; CHECK-SCEV-INV-NEXT: Running pass: LCSSAPass ; CHECK-SCEV-INV-NEXT: Finished {{.*}}Function pass manager run +; CHECK-SCEV-INV-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: AAManager ; CHECK-SCEV-INV-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-SCEV-INV-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -332,6 +338,7 @@ ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: AssumptionAnalysis ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running pass: LCSSAPass ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Finished {{.*}}Function pass manager run +; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: AAManager ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running analysis: ScalarEvolutionAnalysis @@ -344,10 +351,11 @@ ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Clearing all analysis results for: ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Finished {{.*}}Loop pass manager run. ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Invalidating all non-preserved analyses -; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ScalarEvolutionAnalysis +; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Invalidating analysis: MemorySSAAnalysis +; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Invalidating analysis: InnerAnalysisManagerProxy<{{.*}}Loop +; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ScalarEvolutionAnalysis> ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Invalidating all non-preserved analyses ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Invalidating analysis: ScalarEvolutionAnalysis -; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Invalidating analysis: InnerAnalysisManagerProxy<{{.*}}Loop ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running pass: FunctionToLoopPassAdaptor<{{.*}}> on dead_loop ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Starting {{.*}}Function pass manager run ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Running pass: LoopSimplifyPass @@ -355,6 +363,8 @@ ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Finished {{.*}}Function pass manager run ; CHECK-SCEV-INV-AFTER-DELETE-NEXT: Finished {{.*}}Function pass manager run. + + entry: br label %l0.header Index: test/Other/new-pass-manager.ll =================================================================== --- test/Other/new-pass-manager.ll +++ test/Other/new-pass-manager.ll @@ -465,6 +465,7 @@ ; CHECK-REPEAT-LOOP-PASS-NEXT: Invalidating all non-preserved analyses ; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: LCSSAPass ; CHECK-REPEAT-LOOP-PASS-NEXT: Finished llvm::Function pass manager run +; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: MemorySSAAnalysis ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: AAManager ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: ScalarEvolutionAnalysis Index: test/Other/opt-O2-pipeline.ll =================================================================== --- test/Other/opt-O2-pipeline.ll +++ test/Other/opt-O2-pipeline.ll @@ -93,12 +93,13 @@ ; CHECK-NEXT: Simplify the CFG ; CHECK-NEXT: Reassociate expressions ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops @@ -154,12 +155,13 @@ ; CHECK-NEXT: Phi Values Analysis ; CHECK-NEXT: Memory Dependence Analysis ; CHECK-NEXT: Dead Store Elimination +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Loop Invariant Code Motion @@ -186,12 +188,13 @@ ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Float to int ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops @@ -247,6 +250,7 @@ ; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: Optimization Remark Emitter ; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass Index: test/Other/opt-O3-pipeline.ll =================================================================== --- test/Other/opt-O3-pipeline.ll +++ test/Other/opt-O3-pipeline.ll @@ -98,12 +98,13 @@ ; CHECK-NEXT: Simplify the CFG ; CHECK-NEXT: Reassociate expressions ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops @@ -159,12 +160,13 @@ ; CHECK-NEXT: Phi Values Analysis ; CHECK-NEXT: Memory Dependence Analysis ; CHECK-NEXT: Dead Store Elimination +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Loop Invariant Code Motion @@ -191,12 +193,13 @@ ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Float to int ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops @@ -252,6 +255,7 @@ ; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: Optimization Remark Emitter ; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass Index: test/Other/opt-Os-pipeline.ll =================================================================== --- test/Other/opt-Os-pipeline.ll +++ test/Other/opt-Os-pipeline.ll @@ -80,12 +80,13 @@ ; CHECK-NEXT: Simplify the CFG ; CHECK-NEXT: Reassociate expressions ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops @@ -141,12 +142,13 @@ ; CHECK-NEXT: Phi Values Analysis ; CHECK-NEXT: Memory Dependence Analysis ; CHECK-NEXT: Dead Store Elimination +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Loop Invariant Code Motion @@ -173,12 +175,13 @@ ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Float to int ; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) +; CHECK-NEXT: Function Alias Analysis Results +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results ; CHECK-NEXT: Scalar Evolution Analysis ; CHECK-NEXT: Loop Pass Manager ; CHECK-NEXT: Rotate Loops @@ -234,6 +237,7 @@ ; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: Optimization Remark Emitter ; CHECK-NEXT: Combine redundant instructions +; CHECK-NEXT: Memory SSA ; CHECK-NEXT: Canonicalize natural loops ; CHECK-NEXT: LCSSA Verifier ; CHECK-NEXT: Loop-Closed SSA Form Pass Index: test/Transforms/LICM/argmemonly-call.ll =================================================================== --- test/Transforms/LICM/argmemonly-call.ll +++ test/Transforms/LICM/argmemonly-call.ll @@ -101,8 +101,8 @@ ; ALIAS-N2-LABEL: loop: ; CHECK-LABEL: @test5 -; CHECK-LABEL: loop: ; CHECK: @bar +; CHECK-LABEL: loop: br label %loop loop: Index: test/Transforms/LICM/atomics.ll =================================================================== --- test/Transforms/LICM/atomics.ll +++ test/Transforms/LICM/atomics.ll @@ -173,11 +173,10 @@ end: ret i32 %vala ; CHECK-LABEL: define i32 @test7b( -; CHECK-LABEL: entry: -; CHECK: store i32 5, i32* %x ; CHECK-LABEL: loop: ; CHECK: load atomic i32, i32* %y monotonic ; CHECK-LABEL: end: +; CHECK: store i32 5, i32* %x ; CHECK: store atomic i32 %{{.+}}, i32* %z unordered, align 4 } Index: test/Transforms/LICM/guards.ll =================================================================== --- test/Transforms/LICM/guards.ll +++ test/Transforms/LICM/guards.ll @@ -61,13 +61,40 @@ ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT: [[X:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[X_INC:%.*]], [[LOOP]] ] -; CHECK-NEXT: store i32 0, i32* [[P2]] +; CHECK-NEXT: store i32 [[X]], i32* [[P2]] ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[COND:%.*]]) [ "deopt"(i32 0) ] ; CHECK-NEXT: [[VAL:%.*]] = load i32, i32* [[PTR]] ; CHECK-NEXT: [[X_INC]] = add i32 [[X]], [[VAL]] ; CHECK-NEXT: br label [[LOOP]] ; +entry: + br label %loop + +loop: + %x = phi i32 [ 0, %entry ], [ %x.inc, %loop ] + %p2 = getelementptr i32, i32* %ptr, i32 1 + store i32 %x, i32* %p2 + call void (i1, ...) @llvm.experimental.guard(i1 %cond) ["deopt" (i32 0)] + %val = load i32, i32* %ptr + %x.inc = add i32 %x, %val + br label %loop +} + +; But can hoist if the side effect is hoisted. +define void @test2b_prime(i1 %cond, i32* %ptr) { +; CHECK-LABEL: @test2b_prime( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[P2:%.*]] = getelementptr i32, i32* [[PTR:%.*]], i32 1 +; CHECK-NEXT: store i32 0, i32* [[P2]] +; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[COND:%.*]]) [ "deopt"(i32 0) ] +; CHECK-NEXT: [[VAL:%.*]] = load i32, i32* [[PTR]] +; CHECK-NEXT: br label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT: [[X:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[X_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[X_INC]] = add i32 [[X]], [[VAL]] +; CHECK-NEXT: br label [[LOOP]] + entry: br label %loop Index: test/Transforms/LICM/promote-order.ll =================================================================== --- test/Transforms/LICM/promote-order.ll +++ test/Transforms/LICM/promote-order.ll @@ -12,8 +12,8 @@ define i32* @_Z4doiti(i32 %n, float* %tmp1, i32* %tmp3) nounwind { ; CHECK-LABEL: for.body.lr.ph: ; CHECK: store float 1.000000e+00, float* %tmp1 -; CHECK-LABEL: for.cond.for.end_crit_edge: ; CHECK: store i32 1, i32* %tmp3 +; CHECK-LABEL: for.cond.for.end_crit_edge: entry: %cmp1 = icmp slt i32 0, %n Index: test/Transforms/LICM/read-only-calls.ll =================================================================== --- test/Transforms/LICM/read-only-calls.ll +++ test/Transforms/LICM/read-only-calls.ll @@ -16,12 +16,12 @@ ; hoist the load out with the n2-threshold ; since it doesn't alias with the store. ; default AST mechanism clumps all memory locations in one set because of the -; readonly call +; readonly call. Using MemorySSA we can hoist it. define void @test1(i32* %ptr) { ; CHECK-LABEL: @test1( ; CHECK-LABEL: entry: -; CHECK-LABEL: loop: ; CHECK: %val = load i32, i32* %ptr +; CHECK-LABEL: loop: ; ALIAS-N2-LABEL: @test1( ; ALIAS-N2-LABEL: entry: Index: test/Transforms/LICM/store-hoisting.ll =================================================================== --- test/Transforms/LICM/store-hoisting.ll +++ test/Transforms/LICM/store-hoisting.ll @@ -1,6 +1,6 @@ -; RUN: opt -S -basicaa -licm %s | FileCheck -check-prefixes=CHECK,AST %s +; RUN: opt -S -basicaa -licm -enable-mssa-loop-dependency=false %s | FileCheck -check-prefixes=CHECK,AST %s ; RUN: opt -S -basicaa -licm -enable-mssa-loop-dependency=true %s | FileCheck -check-prefixes=CHECK,MSSA %s -; RUN: opt -aa-pipeline=basic-aa -passes='require,require,require,require,loop(licm)' < %s -S | FileCheck -check-prefixes=CHECK,AST %s +; RUN: opt -aa-pipeline=basic-aa -passes='require,require,require,require,loop(licm)' < %s -S | FileCheck -check-prefixes=CHECK,MSSA %s define void @test(i32* %loc) { ; CHECK-LABEL: @test Index: test/Transforms/LoopRotate/pr35210.ll =================================================================== --- test/Transforms/LoopRotate/pr35210.ll +++ test/Transforms/LoopRotate/pr35210.ll @@ -16,6 +16,7 @@ ; CHECK-NEXT: Running analysis: AssumptionAnalysis on f ; CHECK-NEXT: Running pass: LCSSAPass on f ; CHECK-NEXT: Finished llvm::Function pass manager run. +; CHECK-NEXT: Running analysis: MemorySSAAnalysis on f ; CHECK-NEXT: Running analysis: AAManager on f ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f Index: test/Transforms/LoopUnroll/unroll-loop-invalidation.ll =================================================================== --- test/Transforms/LoopUnroll/unroll-loop-invalidation.ll +++ test/Transforms/LoopUnroll/unroll-loop-invalidation.ll @@ -25,10 +25,10 @@ ; CHECK: Clearing all analysis results for: inner2.header ; CHECK: Clearing all analysis results for: outer.header ; CHECK: Invalidating all non-preserved analyses for: test -; CHECK: Invalidating all non-preserved analyses for: inner1.header -; CHECK: Invalidating analysis: LoopAccessAnalysis on inner1.header -; CHECK: Invalidating all non-preserved analyses for: inner1.header.1 -; CHECK-NOT: Invalidating analysis: LoopAccessAnalysis on inner1.header.1 +; CHECK: Clearing all analysis results for: +; CHECK: Clearing all analysis results for: +; CHECK: Invalidating analysis: MemorySSAAnalysis on test +; CHECK: Invalidating analysis: InnerAnalysisManagerProxy ; CHECK: Running pass: FunctionToLoopPassAdaptor ; CHECK: Starting Loop pass manager run. ; CHECK: Running pass: LoopAccessInfoPrinterPass