[PATCH] D71481: [PowerPC][NFC] Refactor splat of constant to vector.
Anil Mahmud via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 10:33:59 PST 2019
anil9 created this revision.
anil9 added reviewers: PowerPC, hfinkel.
Herald added subscribers: shchenz, jsji, kbarton, hiraditya, nemanjai.
Herald added a project: LLVM.
Refactor the splatting of a constant to a vector so that common code is used both for Power9 and Power8.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D71481
Files:
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -8277,8 +8277,6 @@
/// SplatSize. Cast the result to VT.
static SDValue BuildSplatI(int Val, unsigned SplatSize, EVT VT,
SelectionDAG &DAG, const SDLoc &dl) {
- assert(Val >= -16 && Val <= 15 && "vsplti is out of range!");
-
static const MVT VTys[] = { // canonical VT to use for each size.
MVT::v16i8, MVT::v8i16, MVT::Other, MVT::v4i32
};
@@ -8598,29 +8596,8 @@
}
// We have XXSPLTIB for constant splats one byte wide
- if (Subtarget.hasP9Vector() && SplatSize == 1) {
- // This is a splat of 1-byte elements with some elements potentially undef.
- // Rather than trying to match undef in the SDAG patterns, ensure that all
- // elements are the same constant.
- if (HasAnyUndefs || ISD::isBuildVectorAllOnes(BVN)) {
- SmallVector<SDValue, 16> Ops(16, DAG.getConstant(SplatBits,
- dl, MVT::i32));
- SDValue NewBV = DAG.getBuildVector(MVT::v16i8, dl, Ops);
- if (Op.getValueType() != MVT::v16i8)
- 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;
- }
+ if (Subtarget.hasP9Vector() && SplatSize == 1)
+ return BuildSplatI(SplatBits, SplatSize, Op.getValueType(), DAG, dl);
// If the sign extended value is in the range [-16,15], use VSPLTI[bhw].
int32_t SextVal= (int32_t(SplatBits << (32-SplatBitSize)) >>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71481.233832.patch
Type: text/x-patch
Size: 2060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191213/df044ad6/attachment.bin>
More information about the llvm-commits
mailing list