diff options
| author | Nemanja Ivanovic <nemanja.i.ibm@gmail.com> | 2017-08-08 13:52:45 +0000 |
|---|---|---|
| committer | Nemanja Ivanovic <nemanja.i.ibm@gmail.com> | 2017-08-08 13:52:45 +0000 |
| commit | 979dcb6f09f5209489ac6ddc472d4aa7b2d2851a (patch) | |
| tree | b5c20164d0590cda129eed04c722919d743f9f3a /llvm | |
| parent | 75b84fc5cee90696878caf995c77491043cf342e (diff) | |
| download | bcm5719-llvm-979dcb6f09f5209489ac6ddc472d4aa7b2d2851a.tar.gz bcm5719-llvm-979dcb6f09f5209489ac6ddc472d4aa7b2d2851a.zip | |
[PowerPC] Don't crash on larger splats achieved through 1-byte splats
We've implemented a 1-byte splat using XXSPLTISB on P9. However, LLVM will
produce a 1-byte splat even for wider element BUILD_VECTOR nodes. This patch
prevents crashing in that situation.
Differential Revision: https://reviews.llvm.org/D35650
llvm-svn: 310358
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 9 | ||||
| -rw-r--r-- | llvm/test/CodeGen/PowerPC/splat-larger-types-as-v16i8.ll | 20 |
2 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 2c0936b1c64..204bdcc329c 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -7650,6 +7650,15 @@ SDValue PPCTargetLowering::LowerBUILD_VECTOR(SDValue Op, return DAG.getBitcast(Op.getValueType(), NewBV); return NewBV; } + + // BuildVectorSDNode::isConstantSplat() is actually pretty smart. It'll + // detect that constant splats like v8i16: 0xABAB are really just splats + // of a 1-byte constant. In this case, we need to convert the node to a + // splat of v16i8 and a bitcast. + if (Op.getValueType() != MVT::v16i8) + return DAG.getBitcast(Op.getValueType(), + DAG.getConstant(SplatBits, dl, MVT::v16i8)); + return Op; } diff --git a/llvm/test/CodeGen/PowerPC/splat-larger-types-as-v16i8.ll b/llvm/test/CodeGen/PowerPC/splat-larger-types-as-v16i8.ll new file mode 100644 index 00000000000..2ae61f1bb57 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/splat-larger-types-as-v16i8.ll @@ -0,0 +1,20 @@ +; RUN: llc -mcpu=pwr9 -mtriple=powerpc64-unknown-unknown < %s | FileCheck %s +; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-unknown < %s | FileCheck %s +define <8 x i16> @test1() { +entry: + ret <8 x i16> <i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257> +; CHECK-LABEL: test1 +; CHECK: xxspltib 34, 1 +} +define <8 x i16> @testAB() { +entry: +; CHECK-LABEL: testAB +; CHECK: xxspltib 34, 171 + ret <8 x i16> <i16 43947, i16 43947, i16 43947, i16 43947, i16 43947, i16 43947, i16 43947, i16 43947> +} +define <4 x i32> @testAB32() { +entry: +; CHECK-LABEL: testAB32 +; CHECK: xxspltib 34, 171 + ret <4 x i32> <i32 2880154539, i32 2880154539, i32 2880154539, i32 2880154539> +} |

