summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2016-12-15 12:12:45 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2016-12-15 12:12:45 +0000
commit9876ed07f633af7702d4f06de8666a0a48c20fb6 (patch)
treed06576fc7ba7d99f65c7ca6996dc00e15d5eb269 /llvm
parentec02b8d4c03e4c5cb9274fe35a1de1b80067ff2e (diff)
downloadbcm5719-llvm-9876ed07f633af7702d4f06de8666a0a48c20fb6.tar.gz
bcm5719-llvm-9876ed07f633af7702d4f06de8666a0a48c20fb6.zip
[CostModel] Fix long standing bug with reverse shuffle mask detection
Incorrect 'undef' mask index matching meant that broadcast shuffles could be detected as reverse shuffles llvm-svn: 289811
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Analysis/CostModel.cpp2
-rw-r--r--llvm/test/Analysis/CostModel/X86/shuffle-broadcast.ll31
2 files changed, 32 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/CostModel.cpp b/llvm/lib/Analysis/CostModel.cpp
index 5dd54cd4d19..70b3560808c 100644
--- a/llvm/lib/Analysis/CostModel.cpp
+++ b/llvm/lib/Analysis/CostModel.cpp
@@ -92,7 +92,7 @@ CostModelAnalysis::runOnFunction(Function &F) {
static bool isReverseVectorMask(SmallVectorImpl<int> &Mask) {
for (unsigned i = 0, MaskSize = Mask.size(); i < MaskSize; ++i)
- if (Mask[i] > 0 && Mask[i] != (int)(MaskSize - 1 - i))
+ if (Mask[i] >= 0 && Mask[i] != (int)(MaskSize - 1 - i))
return false;
return true;
}
diff --git a/llvm/test/Analysis/CostModel/X86/shuffle-broadcast.ll b/llvm/test/Analysis/CostModel/X86/shuffle-broadcast.ll
new file mode 100644
index 00000000000..579c19eeab1
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/X86/shuffle-broadcast.ll
@@ -0,0 +1,31 @@
+; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-unknown-linux-gnu -mattr=+sse2 | FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=SSE2
+; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-unknown-linux-gnu -mattr=+ssse3 | FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=SSSE3
+; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-unknown-linux-gnu -mattr=+sse4.2 | FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=SSE42
+; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-unknown-linux-gnu -mattr=+avx | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX1
+; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX2
+; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512f | FileCheck %s --check-prefix=CHECK --check-prefix=AVX512 --check-prefix=AVX512F
+; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512f,+avx512bw | FileCheck %s --check-prefix=CHECK --check-prefix=AVX512 --check-prefix=AVX512BW
+
+;
+; Verify the cost model for broadcast shuffles.
+;
+
+; CHECK-LABEL: 'test_vXf64'
+define void @test_vXf64(<2 x double> %src128, <4 x double> %src256, <8 x double> %src512) {
+ ; SSE: Unknown cost {{.*}} %V128 = shufflevector
+ ; AVX: Unknown cost {{.*}} %V128 = shufflevector
+ ; AVX512: Unknown cost {{.*}} %V128 = shufflevector
+ %V128 = shufflevector <2 x double> %src128, <2 x double> undef, <2 x i32> zeroinitializer
+
+ ; SSE: Unknown cost {{.*}} %V256 = shufflevector
+ ; AVX: Unknown cost {{.*}} %V256 = shufflevector
+ ; AVX512: Unknown cost {{.*}} %V256 = shufflevector
+ %V256 = shufflevector <4 x double> %src256, <4 x double> undef, <4 x i32> zeroinitializer
+
+ ; SSE: Unknown cost {{.*}} %V512 = shufflevector
+ ; AVX: Unknown cost {{.*}} %V512 = shufflevector
+ ; AVX512: Unknown cost {{.*}} %V512 = shufflevector
+ %V512 = shufflevector <8 x double> %src512, <8 x double> undef, <8 x i32> zeroinitializer
+
+ ret void
+}
OpenPOWER on IntegriCloud