Index: clang/test/CodeGen/matrix-lowering-opt-levels.c =================================================================== --- /dev/null +++ clang/test/CodeGen/matrix-lowering-opt-levels.c @@ -0,0 +1,20 @@ +// RUN: %clang -O0 -fenable-matrix -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang -O1 -fenable-matrix -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang -O2 -fenable-matrix -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang -O3 -fenable-matrix -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang -Ofast -fenable-matrix -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang -Os -fenable-matrix -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang -Oz -fenable-matrix -S -emit-llvm %s -o - | FileCheck %s + +// Smoke test that the matrix intrinsics are lowered at any optimisation level. + +typedef float m4x4_t __attribute__((matrix_type(4, 4))); + +m4x4_t f(m4x4_t a, m4x4_t b, m4x4_t c) { + // + // CHECK-LABEL: f( + // CHECK-NOT: @llvm.matrix + // CHECK: } + // + return a + b * c; +} Index: clang/test/CodeGen/thinlto-distributed-newpm.ll =================================================================== --- clang/test/CodeGen/thinlto-distributed-newpm.ll +++ clang/test/CodeGen/thinlto-distributed-newpm.ll @@ -36,13 +36,20 @@ ; CHECK-O: Running pass: InferFunctionAttrsPass ; CHECK-O: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function>{{ ?}}> ; CHECK-O: Starting {{.*}}Function pass manager run. -; CHECK-O: Running pass: SimplifyCFGPass on main +; CHECK-O: Running pass: LowerMatrixIntrinsicsPass on main ; CHECK-O: Running analysis: TargetIRAnalysis on main +; CHECK-O: Running analysis: AAManager on main +; CHECK-O: Running analysis: TargetLibraryAnalysis on main +; CHECK-O: Running analysis: BasicAA on main ; CHECK-O: Running analysis: AssumptionAnalysis on main -; CHECK-O: Running pass: SROA on main ; CHECK-O: Running analysis: DominatorTreeAnalysis on main +; CHECK-O: Running analysis: ScopedNoAliasAA on main +; CHECK-O: Running analysis: TypeBasedAA on main +; CHECK-O: Running analysis: OuterAnalysisManagerProxy +; CHECK-O: Running analysis: LoopAnalysis on main +; CHECK-O: Running pass: SimplifyCFGPass on main +; CHECK-O: Running pass: SROA on main ; CHECK-O: Running pass: EarlyCSEPass on main -; CHECK-O: Running analysis: TargetLibraryAnalysis on main ; CHECK-O: Running pass: LowerExpectIntrinsicPass on main ; CHECK-O3: Running pass: CallSiteSplittingPass on main ; CHECK-O: Finished {{.*}}Function pass manager run. Index: llvm/lib/Passes/PassBuilder.cpp =================================================================== --- llvm/lib/Passes/PassBuilder.cpp +++ llvm/lib/Passes/PassBuilder.cpp @@ -929,6 +929,8 @@ // Create an early function pass manager to cleanup the output of the // frontend. FunctionPassManager EarlyFPM(DebugLogging); + + EarlyFPM.addPass(LowerMatrixIntrinsicsPass()); EarlyFPM.addPass(SimplifyCFGPass()); EarlyFPM.addPass(SROA()); EarlyFPM.addPass(EarlyCSEPass()); Index: llvm/test/Other/new-pm-thinlto-defaults.ll =================================================================== --- llvm/test/Other/new-pm-thinlto-defaults.ll +++ llvm/test/Other/new-pm-thinlto-defaults.ll @@ -69,13 +69,17 @@ ; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> ; CHECK-PRELINK-O-NEXT: Running analysis: PassInstrumentationAnalysis ; CHECK-O-NEXT: Starting llvm::Function pass manager run. -; CHECK-O-NEXT: Running pass: SimplifyCFGPass +; CHECK-O-NEXT: Running pass: LowerMatrixIntrinsicsPass ; CHECK-O-NEXT: Running analysis: TargetIRAnalysis +; CHECK-PRELINK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis +; CHECK-O-NEXT: Running analysis: AAManager +; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis +; CHECK-O-NEXT: Running analysis: DominatorTreeAnalysis +; CHECK-O-NEXT: Running analysis: LoopAnalysis +; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running analysis: AssumptionAnalysis ; CHECK-O-NEXT: Running pass: SROA -; CHECK-O-NEXT: Running analysis: DominatorTreeAnalysis ; CHECK-O-NEXT: Running pass: EarlyCSEPass -; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass ; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass ; CHECK-O-NEXT: Finished llvm::Function pass manager run. @@ -88,8 +92,6 @@ ; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> ; CHECK-O-NEXT: Starting llvm::Function pass manager run. ; CHECK-O-NEXT: Running pass: InstCombinePass -; CHECK-PRELINK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis -; CHECK-O-NEXT: Running analysis: AAManager ; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy ; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Finished llvm::Function pass manager run. @@ -135,7 +137,6 @@ ; CHECK-O-NEXT: Running pass: FunctionToLoopPassAdaptor<{{.*}}LoopStandardAnalysisResults{{.*}}> ; CHECK-O-NEXT: Starting llvm::Function pass manager run ; CHECK-O-NEXT: Running pass: LoopSimplifyPass -; CHECK-O-NEXT: Running analysis: LoopAnalysis ; CHECK-O-NEXT: Running pass: LCSSAPass ; CHECK-O-NEXT: Finished llvm::Function pass manager run ; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis Index: llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll =================================================================== --- llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll +++ llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll @@ -38,13 +38,16 @@ ; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis ; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> ; CHECK-O-NEXT: Starting {{.*}}Function pass manager run. -; CHECK-O-NEXT: Running pass: SimplifyCFGPass +; CHECK-O-NEXT: Running pass: LowerMatrixIntrinsicsPass ; CHECK-O-NEXT: Running analysis: TargetIRAnalysis +; CHECK-O-NEXT: Running analysis: AAManager +; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis +; CHECK-O-NEXT: Running analysis: DominatorTreeAnalysis +; CHECK-O-NEXT: Running analysis: LoopAnalysis +; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running analysis: AssumptionAnalysis ; CHECK-O-NEXT: Running pass: SROA -; CHECK-O-NEXT: Running analysis: DominatorTreeAnalysis ; CHECK-O-NEXT: Running pass: EarlyCSEPass -; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass ; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass ; CHECK-O-NEXT: Finished {{.*}}Function pass manager run. @@ -57,12 +60,10 @@ ; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> ; CHECK-O-NEXT: Starting {{.*}}Function pass manager run. ; CHECK-O-NEXT: Running pass: InstCombinePass -; CHECK-O-NEXT: Running analysis: AAManager ; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy ; CHECK-O-NEXT: Running analysis: BlockFrequencyAnalysis on foo ; These next two can appear in any order since they are accessed as parameters ; on the same call to BlockFrequencyInfo::calculate. -; CHECK-O-DAG: Running analysis: LoopAnalysis on foo ; CHECK-O-DAG: Running analysis: BranchProbabilityAnalysis on foo ; CHECK-O-NEXT: Running analysis: PostDominatorTreeAnalysis on foo ; CHECK-O-NEXT: Running pass: SimplifyCFGPass Index: llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll =================================================================== --- llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll +++ llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll @@ -40,18 +40,20 @@ ; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> ; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis ; CHECK-O-NEXT: Starting {{.*}}Function pass manager run. -; CHECK-O-NEXT: Running pass: SimplifyCFGPass +; CHECK-O-NEXT: Running pass: LowerMatrixIntrinsicsPass ; CHECK-O-NEXT: Running analysis: TargetIRAnalysis +; CHECK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis +; CHECK-O-NEXT: Running analysis: AAManager +; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis +; CHECK-O-NEXT: Running analysis: DominatorTreeAnalysis +; CHECK-O-NEXT: Running analysis: LoopAnalysis +; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running analysis: AssumptionAnalysis ; CHECK-O-NEXT: Running pass: SROA -; CHECK-O-NEXT: Running analysis: DominatorTreeAnalysis ; CHECK-O-NEXT: Running pass: EarlyCSEPass -; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass ; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass ; CHECK-O-NEXT: Running pass: InstCombinePass on foo -; CHECK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis on foo -; CHECK-O-NEXT: Running analysis: AAManager on foo ; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy ; CHECK-O-NEXT: Finished {{.*}}Function pass manager run. ; CHECK-O-NEXT: Running pass: SampleProfileLoaderPass @@ -71,7 +73,6 @@ ; CHECK-O-NEXT: Running analysis: BlockFrequencyAnalysis on foo ; These next two can appear in any order since they are accessed as parameters ; on the same call to BlockFrequencyInfo::calculate. -; CHECK-O-DAG: Running analysis: LoopAnalysis on foo ; CHECK-O-DAG: Running analysis: BranchProbabilityAnalysis on foo ; CHECK-O-NEXT: Running analysis: PostDominatorTreeAnalysis on foo ; CHECK-O-NEXT: Running pass: SimplifyCFGPass on foo Index: llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll =================================================================== --- llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll +++ llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll @@ -42,13 +42,17 @@ ; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> ; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis ; CHECK-O-NEXT: Starting {{.*}}Function pass manager run. -; CHECK-O-NEXT: Running pass: SimplifyCFGPass +; CHECK-O-NEXT: Running pass: LowerMatrixIntrinsicsPass ; CHECK-O-NEXT: Running analysis: TargetIRAnalysis +; CHECK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis +; CHECK-O-NEXT: Running analysis: AAManager +; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis +; CHECK-O-NEXT: Running analysis: DominatorTreeAnalysis +; CHECK-O-NEXT: Running analysis: LoopAnalysis +; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running analysis: AssumptionAnalysis ; CHECK-O-NEXT: Running pass: SROA -; CHECK-O-NEXT: Running analysis: DominatorTreeAnalysis ; CHECK-O-NEXT: Running pass: EarlyCSEPass -; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass ; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass ; CHECK-O-NEXT: Finished {{.*}}Function pass manager run. @@ -60,8 +64,6 @@ ; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> ; CHECK-O-NEXT: Starting {{.*}}Function pass manager run. ; CHECK-O-NEXT: Running pass: InstCombinePass -; CHECK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis -; CHECK-O-NEXT: Running analysis: AAManager ; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy ; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Finished {{.*}}Function pass manager run. @@ -86,7 +88,6 @@ ; on the same call to BlockFrequencyInfo::calculate. ; CHECK-O-DAG: Running analysis: BranchProbabilityAnalysis on foo ; CHECK-O-DAG: Running analysis: PostDominatorTreeAnalysis on foo -; CHECK-O-DAG: Running analysis: LoopAnalysis on foo ; CHECK-O-NEXT: Running analysis: BlockFrequencyAnalysis on foo ; CHECK-O-NEXT: Invalidating all non-preserved analyses for: ; CHECK-O-NEXT: Invalidating analysis: InnerAnalysisManagerProxy Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll =================================================================== --- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll +++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll @@ -41,18 +41,20 @@ ; CHECK-O-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> ; CHECK-O-NEXT: Running analysis: PassInstrumentationAnalysis ; CHECK-O-NEXT: Starting {{.*}}Function pass manager run. -; CHECK-O-NEXT: Running pass: SimplifyCFGPass +; CHECK-O-NEXT: Running pass: LowerMatrixIntrinsicsPass ; CHECK-O-NEXT: Running analysis: TargetIRAnalysis +; CHECK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis +; CHECK-O-NEXT: Running analysis: AAManager +; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis +; CHECK-O-NEXT: Running analysis: DominatorTreeAnalysis +; CHECK-O-NEXT: Running analysis: LoopAnalysis +; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running analysis: AssumptionAnalysis ; CHECK-O-NEXT: Running pass: SROA -; CHECK-O-NEXT: Running analysis: DominatorTreeAnalysis ; CHECK-O-NEXT: Running pass: EarlyCSEPass -; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis ; CHECK-O-NEXT: Running pass: LowerExpectIntrinsicPass ; CHECK-O3-NEXT: Running pass: CallSiteSplittingPass ; CHECK-O-NEXT: Running pass: InstCombinePass on foo -; CHECK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis on foo -; CHECK-O-NEXT: Running analysis: AAManager on foo ; CHECK-O-NEXT: Running analysis: OuterAnalysisManagerProxy ; CHECK-O-NEXT: Finished {{.*}}Function pass manager run. ; CHECK-O-NEXT: Running pass: SampleProfileLoaderPass @@ -70,7 +72,6 @@ ; CHECK-O-NEXT: Running analysis: BlockFrequencyAnalysis on foo ; These next two can appear in any order since they are accessed as parameters ; on the same call to BlockFrequencyInfo::calculate. -; CHECK-O-DAG: Running analysis: LoopAnalysis on foo ; CHECK-O-DAG: Running analysis: BranchProbabilityAnalysis on foo ; CHECK-O-NEXT: Running analysis: PostDominatorTreeAnalysis on foo ; CHECK-O-NEXT: Running pass: SimplifyCFGPass on foo