| 1 |
From cf00b30288c4c81b2c6a5af01c38f236148777a0 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Mike Hommey <[email protected]> |
| 3 |
Date: Tue, 28 Mar 2023 06:13:36 +0900 |
| 4 |
Subject: [PATCH] Revert "[Passes][VectorCombine] enable early run generally |
| 5 |
and try load folds" |
| 6 |
|
| 7 |
This reverts commit 163bb6d64e5f1220777c3ec2a8b58c0666a74d91. |
| 8 |
It causes various reftest regressions. |
| 9 |
--- |
| 10 |
llvm/lib/Passes/PassBuilderPipelines.cpp | 7 ++++--- |
| 11 |
llvm/lib/Transforms/Vectorize/VectorCombine.cpp | 8 ++------ |
| 12 |
llvm/test/Other/new-pm-defaults.ll | 2 +- |
| 13 |
.../Other/new-pm-thinlto-postlink-defaults.ll | 1 - |
| 14 |
.../Other/new-pm-thinlto-postlink-pgo-defaults.ll | 1 - |
| 15 |
.../new-pm-thinlto-postlink-samplepgo-defaults.ll | 1 - |
| 16 |
.../Other/new-pm-thinlto-prelink-pgo-defaults.ll | 1 - |
| 17 |
.../new-pm-thinlto-prelink-samplepgo-defaults.ll | 1 - |
| 18 |
.../PhaseOrdering/X86/vec-load-combine.ll | 15 +++++++++++---- |
| 19 |
9 files changed, 18 insertions(+), 19 deletions(-) |
| 20 |
|
| 21 |
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp |
| 22 |
index d737ea5ab070..54f8c09a0751 100644 |
| 23 |
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp |
| 24 |
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp |
| 25 |
@@ -703,9 +703,10 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level, |
| 26 |
// Delete small array after loop unroll. |
| 27 |
FPM.addPass(SROAPass(SROAOptions::ModifyCFG)); |
| 28 |
|
| 29 |
- // Try vectorization/scalarization transforms that are both improvements |
| 30 |
- // themselves and can allow further folds with GVN and InstCombine. |
| 31 |
- FPM.addPass(VectorCombinePass(/*TryEarlyFoldsOnly=*/true)); |
| 32 |
+ // The matrix extension can introduce large vector operations early, which can |
| 33 |
+ // benefit from running vector-combine early on. |
| 34 |
+ if (EnableMatrix) |
| 35 |
+ FPM.addPass(VectorCombinePass(/*TryEarlyFoldsOnly=*/true)); |
| 36 |
|
| 37 |
// Eliminate redundancies. |
| 38 |
FPM.addPass(MergedLoadStoreMotionPass()); |
| 39 |
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp |
| 40 |
index ecbc13d489eb..a43724d467ec 100644 |
| 41 |
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp |
| 42 |
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp |
| 43 |
@@ -3092,23 +3092,6 @@ bool VectorCombine::run() { |
| 44 |
|
| 45 |
LLVM_DEBUG(dbgs() << "VC: Visiting: " << I << '\n'); |
| 46 |
|
| 47 |
- // These folds should be beneficial regardless of when this pass is run |
| 48 |
- // in the optimization pipeline. |
| 49 |
- // The type checking is for run-time efficiency. We can avoid wasting time |
| 50 |
- // dispatching to folding functions if there's no chance of matching. |
| 51 |
- if (IsFixedVectorType) { |
| 52 |
- switch (Opcode) { |
| 53 |
- case Instruction::InsertElement: |
| 54 |
- MadeChange |= vectorizeLoadInsert(I); |
| 55 |
- break; |
| 56 |
- case Instruction::ShuffleVector: |
| 57 |
- MadeChange |= widenSubvectorLoad(I); |
| 58 |
- break; |
| 59 |
- default: |
| 60 |
- break; |
| 61 |
- } |
| 62 |
- } |
| 63 |
- |
| 64 |
// This transform works with scalable and fixed vectors |
| 65 |
// TODO: Identify and allow other scalable transforms |
| 66 |
if (IsVectorType) { |
| 67 |
@@ -3131,10 +3114,12 @@ bool VectorCombine::run() { |
| 68 |
if (IsFixedVectorType) { |
| 69 |
switch (Opcode) { |
| 70 |
case Instruction::InsertElement: |
| 71 |
+ MadeChange |= vectorizeLoadInsert(I); |
| 72 |
MadeChange |= foldInsExtFNeg(I); |
| 73 |
MadeChange |= foldInsExtVectorToShuffle(I); |
| 74 |
break; |
| 75 |
case Instruction::ShuffleVector: |
| 76 |
+ MadeChange |= widenSubvectorLoad(I); |
| 77 |
MadeChange |= foldPermuteOfBinops(I); |
| 78 |
MadeChange |= foldShuffleOfBinops(I); |
| 79 |
MadeChange |= foldShuffleOfCastops(I); |
| 80 |
diff --git a/llvm/test/Other/new-pm-defaults.ll b/llvm/test/Other/new-pm-defaults.ll |
| 81 |
index 7cf035b0c6f3..33cbb433640b 100644 |
| 82 |
--- a/llvm/test/Other/new-pm-defaults.ll |
| 83 |
+++ b/llvm/test/Other/new-pm-defaults.ll |
| 84 |
@@ -194,7 +194,7 @@ |
| 85 |
; CHECK-O-NEXT: Running pass: LoopFullUnrollPass |
| 86 |
; CHECK-EP-LOOP-END-NEXT: Running pass: NoOpLoopPass |
| 87 |
; CHECK-O-NEXT: Running pass: SROAPass on foo |
| 88 |
-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass |
| 89 |
+; CHECK-MATRIX: Running pass: VectorCombinePass |
| 90 |
; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass |
| 91 |
; CHECK-O23SZ-NEXT: Running pass: GVNPass |
| 92 |
; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis |
| 93 |
diff --git a/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll |
| 94 |
index ed13402e1c4b..5d8712841801 100644 |
| 95 |
--- a/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll |
| 96 |
+++ b/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll |
| 97 |
@@ -124,7 +124,6 @@ |
| 98 |
; CHECK-O-NEXT: Running pass: LoopDeletionPass |
| 99 |
; CHECK-O-NEXT: Running pass: LoopFullUnrollPass |
| 100 |
; CHECK-O-NEXT: Running pass: SROAPass on foo |
| 101 |
-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass |
| 102 |
; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass |
| 103 |
; CHECK-O23SZ-NEXT: Running pass: GVNPass |
| 104 |
; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis |
| 105 |
diff --git a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll |
| 106 |
index c82c34f7ff01..c6f95b393170 100644 |
| 107 |
--- a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll |
| 108 |
+++ b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll |
| 109 |
@@ -110,7 +110,6 @@ |
| 110 |
; CHECK-O-NEXT: Running pass: LoopDeletionPass |
| 111 |
; CHECK-O-NEXT: Running pass: LoopFullUnrollPass |
| 112 |
; CHECK-O-NEXT: Running pass: SROAPass on foo |
| 113 |
-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass |
| 114 |
; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass |
| 115 |
; CHECK-O23SZ-NEXT: Running pass: GVNPass |
| 116 |
; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis |
| 117 |
diff --git a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll |
| 118 |
index d375747547d6..b17556bc528a 100644 |
| 119 |
--- a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll |
| 120 |
+++ b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll |
| 121 |
@@ -119,7 +119,6 @@ |
| 122 |
; CHECK-O-NEXT: Running pass: LoopDeletionPass |
| 123 |
; CHECK-O-NEXT: Running pass: LoopFullUnrollPass |
| 124 |
; CHECK-O-NEXT: Running pass: SROAPass on foo |
| 125 |
-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass |
| 126 |
; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass |
| 127 |
; CHECK-O23SZ-NEXT: Running pass: GVNPass |
| 128 |
; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis |
| 129 |
diff --git a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll |
| 130 |
index f6a940659680..8551ea2bc998 100644 |
| 131 |
--- a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll |
| 132 |
+++ b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll |
| 133 |
@@ -159,7 +159,6 @@ |
| 134 |
; CHECK-O-NEXT: Running pass: LoopDeletionPass |
| 135 |
; CHECK-O-NEXT: Running pass: LoopFullUnrollPass |
| 136 |
; CHECK-O-NEXT: Running pass: SROAPass on foo |
| 137 |
-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass |
| 138 |
; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass |
| 139 |
; CHECK-O23SZ-NEXT: Running pass: GVNPass |
| 140 |
; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis |
| 141 |
diff --git a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll |
| 142 |
index 48a9433d2499..531dc0361873 100644 |
| 143 |
--- a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll |
| 144 |
+++ b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll |
| 145 |
@@ -123,7 +123,6 @@ |
| 146 |
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass |
| 147 |
; CHECK-O-NEXT: Running pass: LoopDeletionPass |
| 148 |
; CHECK-O-NEXT: Running pass: SROAPass on foo |
| 149 |
-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass |
| 150 |
; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass |
| 151 |
; CHECK-O23SZ-NEXT: Running pass: GVNPass |
| 152 |
; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis |
| 153 |
diff --git a/llvm/test/Transforms/PhaseOrdering/X86/vec-load-combine.ll b/llvm/test/Transforms/PhaseOrdering/X86/vec-load-combine.ll |
| 154 |
index 85f6fceb5bdb..2d20250dfd81 100644 |
| 155 |
--- a/llvm/test/Transforms/PhaseOrdering/X86/vec-load-combine.ll |
| 156 |
+++ b/llvm/test/Transforms/PhaseOrdering/X86/vec-load-combine.ll |
| 157 |
@@ -12,13 +12,20 @@ $getAt = comdat any |
| 158 |
define dso_local noundef <4 x float> @ConvertVectors_ByRef(ptr noundef nonnull align 16 dereferenceable(16) %0) #0 { |
| 159 |
; SSE-LABEL: @ConvertVectors_ByRef( |
| 160 |
; SSE-NEXT: [[TMP2:%.*]] = load <4 x float>, ptr [[TMP0:%.*]], align 16 |
| 161 |
-; SSE-NEXT: [[TMP3:%.*]] = shufflevector <4 x float> [[TMP2]], <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 2> |
| 162 |
-; SSE-NEXT: ret <4 x float> [[TMP3]] |
| 163 |
+; SSE-NEXT: [[TMP3:%.*]] = getelementptr inbounds [4 x float], ptr [[TMP0]], i64 0, i64 1 |
| 164 |
+; SSE-NEXT: [[TMP4:%.*]] = load <2 x float>, ptr [[TMP3]], align 4 |
| 165 |
+; SSE-NEXT: [[TMP5:%.*]] = shufflevector <2 x float> [[TMP4]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef> |
| 166 |
+; SSE-NEXT: [[TMP6:%.*]] = shufflevector <4 x float> [[TMP2]], <4 x float> [[TMP5]], <4 x i32> <i32 0, i32 4, i32 5, i32 undef> |
| 167 |
+; SSE-NEXT: [[TMP7:%.*]] = shufflevector <4 x float> [[TMP6]], <4 x float> [[TMP5]], <4 x i32> <i32 0, i32 1, i32 2, i32 5> |
| 168 |
+; SSE-NEXT: ret <4 x float> [[TMP7]] |
| 169 |
; |
| 170 |
; AVX-LABEL: @ConvertVectors_ByRef( |
| 171 |
; AVX-NEXT: [[TMP2:%.*]] = load <4 x float>, ptr [[TMP0:%.*]], align 16 |
| 172 |
-; AVX-NEXT: [[TMP3:%.*]] = shufflevector <4 x float> [[TMP2]], <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 2> |
| 173 |
-; AVX-NEXT: ret <4 x float> [[TMP3]] |
| 174 |
+; AVX-NEXT: [[TMP3:%.*]] = getelementptr inbounds [4 x float], ptr [[TMP0]], i64 0, i64 2 |
| 175 |
+; AVX-NEXT: [[TMP4:%.*]] = load float, ptr [[TMP3]], align 8 |
| 176 |
+; AVX-NEXT: [[TMP5:%.*]] = insertelement <4 x float> [[TMP2]], float [[TMP4]], i64 2 |
| 177 |
+; AVX-NEXT: [[TMP6:%.*]] = insertelement <4 x float> [[TMP5]], float [[TMP4]], i64 3 |
| 178 |
+; AVX-NEXT: ret <4 x float> [[TMP6]] |
| 179 |
; |
| 180 |
%2 = alloca ptr, align 8 |
| 181 |
%3 = alloca <4 x float>, align 16 |
| 182 |
-- |
| 183 |
2.47.0.1.g59ce1bf855 |
| 184 |
|