diff options
author | Nemanja Ivanovic <nemanja.i.ibm@gmail.com> | 2016-12-15 11:16:20 +0000 |
---|---|---|
committer | Nemanja Ivanovic <nemanja.i.ibm@gmail.com> | 2016-12-15 11:16:20 +0000 |
commit | 552c8e960e9e88d3c96a467df2e37efa27eff7d2 (patch) | |
tree | 8bc97c5b90a9f8ea308ea18516cbd08c0b11e56d | |
parent | 4f590f28e7739f139f6a23ebe426fd4e1557d470 (diff) | |
download | bcm5719-llvm-552c8e960e9e88d3c96a467df2e37efa27eff7d2.tar.gz bcm5719-llvm-552c8e960e9e88d3c96a467df2e37efa27eff7d2.zip |
[Power9] Allow AnyExt immediates for XXSPLTIB
In some situations, the BUILD_VECTOR node that builds a v18i8 vector by
a splat of an i8 constant will end up with signed 8-bit values and other
situations, it'll end up with unsigned ones. Handle both situations.
Fixes PR31340.
llvm-svn: 289804
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCInstrInfo.td | 2 | ||||
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCInstrVSX.td | 12 | ||||
-rw-r--r-- | llvm/test/CodeGen/PowerPC/power9-moves-and-splats.ll | 9 |
3 files changed, 16 insertions, 7 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.td b/llvm/lib/Target/PowerPC/PPCInstrInfo.td index 074fa815293..a7231bd2e2c 100644 --- a/llvm/lib/Target/PowerPC/PPCInstrInfo.td +++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.td @@ -326,7 +326,7 @@ def immZExt16 : PatLeaf<(imm), [{ // field. Used by instructions like 'ori'. return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue(); }], LO16>; -def immSExt8 : ImmLeaf<i32, [{ return isInt<8>(Imm); }]>; +def immAnyExt8 : ImmLeaf<i32, [{ return isInt<8>(Imm) || isUInt<8>(Imm); }]>; def immSExt5NonZero : ImmLeaf<i32, [{ return Imm && isInt<5>(Imm); }]>; // imm16Shifted* - These match immediates where the low 16-bits are zero. There diff --git a/llvm/lib/Target/PowerPC/PPCInstrVSX.td b/llvm/lib/Target/PowerPC/PPCInstrVSX.td index dcb49b0b024..0d9e3459f47 100644 --- a/llvm/lib/Target/PowerPC/PPCInstrVSX.td +++ b/llvm/lib/Target/PowerPC/PPCInstrVSX.td @@ -2865,12 +2865,12 @@ let AddedComplexity = 400 in { (v4i32 (MTVSRWS $A))>; def : Pat<(v4i32 (build_vector i32:$A, i32:$A, i32:$A, i32:$A)), (v4i32 (MTVSRWS $A))>; - def : Pat<(v16i8 (build_vector immSExt8:$A, immSExt8:$A, immSExt8:$A, - immSExt8:$A, immSExt8:$A, immSExt8:$A, - immSExt8:$A, immSExt8:$A, immSExt8:$A, - immSExt8:$A, immSExt8:$A, immSExt8:$A, - immSExt8:$A, immSExt8:$A, immSExt8:$A, - immSExt8:$A)), + def : Pat<(v16i8 (build_vector immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A, + immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A, + immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A, + immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A, + immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A, + immAnyExt8:$A)), (v16i8 (COPY_TO_REGCLASS (XXSPLTIB imm:$A), VSRC))>; def : Pat<(v16i8 immAllOnesV), (v16i8 (COPY_TO_REGCLASS (XXSPLTIB 255), VSRC))>; diff --git a/llvm/test/CodeGen/PowerPC/power9-moves-and-splats.ll b/llvm/test/CodeGen/PowerPC/power9-moves-and-splats.ll index 54eea6ae828..fc676cc0885 100644 --- a/llvm/test/CodeGen/PowerPC/power9-moves-and-splats.ll +++ b/llvm/test/CodeGen/PowerPC/power9-moves-and-splats.ll @@ -152,6 +152,15 @@ entry: ret <16 x i8> <i8 -127, i8 -127, i8 -127, i8 -127, i8 -127, i8 -127, i8 -127, i8 -127, i8 -127, i8 -127, i8 -127, i8 -127, i8 -127, i8 -127, i8 -127, i8 -127> } +define <16 x i8> @test13E127() { +entry: +; CHECK-LABEL: test13E127 +; CHECK: xxspltib 34, 200 +; CHECK-BE-LABEL: test13E127 +; CHECK-BE: xxspltib 34, 200 + ret <16 x i8> <i8 200, i8 200, i8 200, i8 200, i8 200, i8 200, i8 200, i8 200, i8 200, i8 200, i8 200, i8 200, i8 200, i8 200, i8 200, i8 200> +} + define <4 x i32> @test14(<4 x i32> %a, i32* nocapture readonly %b) { entry: ; CHECK-LABEL: test14 |