Skip to content

Commit 6fd994b

Browse files
author
Krzysztof Parzyszek
committed
[Hexagon] Remove ISD node VSPLATW, use VSPLAT instead
This is a step towards improving HVX codegen for splat.
1 parent 33bb3ef commit 6fd994b

File tree

4 files changed

+11
-26
lines changed

4 files changed

+11
-26
lines changed

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,6 @@ const char* HexagonTargetLowering::getTargetNodeName(unsigned Opcode) const {
18511851
case HexagonISD::PTRUE: return "HexagonISD::PTRUE";
18521852
case HexagonISD::PFALSE: return "HexagonISD::PFALSE";
18531853
case HexagonISD::VZERO: return "HexagonISD::VZERO";
1854-
case HexagonISD::VSPLATW: return "HexagonISD::VSPLATW";
18551854
case HexagonISD::D2P: return "HexagonISD::D2P";
18561855
case HexagonISD::P2D: return "HexagonISD::P2D";
18571856
case HexagonISD::V2Q: return "HexagonISD::V2Q";

llvm/lib/Target/Hexagon/HexagonISelLowering.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ enum NodeType : unsigned {
8282
QTRUE,
8383
QFALSE,
8484
VZERO,
85-
VSPLATW, // HVX splat of a 32-bit word with an arbitrary result type.
8685
TYPECAST, // No-op that's used to convert between different legal
8786
// types in a register.
8887
VALIGN, // Align two vectors (in Op0, Op1) to one that would have

llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,9 @@ HexagonTargetLowering::buildHvxVectorReg(ArrayRef<SDValue> Values,
496496
auto *IdxN = dyn_cast<ConstantSDNode>(SplatV.getNode());
497497
if (IdxN && IdxN->isNullValue())
498498
return getZero(dl, VecTy, DAG);
499-
return DAG.getNode(HexagonISD::VSPLATW, dl, VecTy, SplatV);
499+
MVT WordTy = MVT::getVectorVT(MVT::i32, HwLen/4);
500+
SDValue S = DAG.getNode(HexagonISD::VSPLAT, dl, WordTy, SplatV);
501+
return DAG.getBitcast(VecTy, S);
500502
}
501503

502504
// Delay recognizing constant vectors until here, so that we can generate
@@ -1421,19 +1423,14 @@ HexagonTargetLowering::LowerHvxCttz(SDValue Op, SelectionDAG &DAG) const {
14211423
// Calculate the vectors of 1 and bitwidth(x).
14221424
MVT ElemTy = ty(InpV).getVectorElementType();
14231425
unsigned ElemWidth = ElemTy.getSizeInBits();
1424-
// Using uint64_t because a shift by 32 can happen.
1425-
uint64_t Splat1 = 0, SplatW = 0;
1426-
assert(isPowerOf2_32(ElemWidth) && ElemWidth <= 32);
1427-
for (unsigned i = 0; i != 32/ElemWidth; ++i) {
1428-
Splat1 = (Splat1 << ElemWidth) | 1;
1429-
SplatW = (SplatW << ElemWidth) | ElemWidth;
1430-
}
1431-
SDValue Vec1 = DAG.getNode(HexagonISD::VSPLATW, dl, ResTy,
1432-
DAG.getConstant(uint32_t(Splat1), dl, MVT::i32));
1433-
SDValue VecW = DAG.getNode(HexagonISD::VSPLATW, dl, ResTy,
1434-
DAG.getConstant(uint32_t(SplatW), dl, MVT::i32));
1435-
SDValue VecN1 = DAG.getNode(HexagonISD::VSPLATW, dl, ResTy,
1426+
1427+
SDValue Vec1 = DAG.getNode(HexagonISD::VSPLAT, dl, ResTy,
1428+
DAG.getConstant(1, dl, MVT::i32));
1429+
SDValue VecW = DAG.getNode(HexagonISD::VSPLAT, dl, ResTy,
1430+
DAG.getConstant(ElemWidth, dl, MVT::i32));
1431+
SDValue VecN1 = DAG.getNode(HexagonISD::VSPLAT, dl, ResTy,
14361432
DAG.getConstant(-1, dl, MVT::i32));
1433+
14371434
// Do not use DAG.getNOT, because that would create BUILD_VECTOR with
14381435
// a BITCAST. Here we can skip the BITCAST (so we don't have to handle
14391436
// it separately in custom combine or selection).

llvm/lib/Target/Hexagon/HexagonPatternsHVX.td

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ def SDTHexagonVINSERTW0: SDTypeProfile<1, 2,
1212
[SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisVT<2, i32>]>;
1313
def HexagonVINSERTW0: SDNode<"HexagonISD::VINSERTW0", SDTHexagonVINSERTW0>;
1414

15-
def SDTHexagonVSPLATW: SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>;
16-
def HexagonVSPLATW: SDNode<"HexagonISD::VSPLATW", SDTHexagonVSPLATW>;
17-
1815
def HwLen2: SDNodeXForm<imm, [{
1916
const auto &ST = static_cast<const HexagonSubtarget&>(CurDAG->getSubtarget());
2017
return CurDAG->getTargetConstant(ST.getVectorLength()/2, SDLoc(N), MVT::i32);
@@ -242,17 +239,10 @@ let Predicates = [UseHVX] in {
242239
def: Pat<(VecPI8 (HexagonVSPLAT I32:$Rs)), (Rep (Vsplatrb $Rs))>;
243240
def: Pat<(VecPI16 (HexagonVSPLAT I32:$Rs)), (Rep (Vsplatrh $Rs))>;
244241
def: Pat<(VecPI32 (HexagonVSPLAT I32:$Rs)), (Rep (Vsplatrw $Rs))>;
245-
246-
def: Pat<(VecI8 (HexagonVSPLATW I32:$Rs)), (Vsplatrw $Rs)>;
247-
def: Pat<(VecI16 (HexagonVSPLATW I32:$Rs)), (Vsplatrw $Rs)>;
248-
def: Pat<(VecI32 (HexagonVSPLATW I32:$Rs)), (Vsplatrw $Rs)>;
249-
def: Pat<(VecPI8 (HexagonVSPLATW I32:$Rs)), (Rep (Vsplatrw $Rs))>;
250-
def: Pat<(VecPI16 (HexagonVSPLATW I32:$Rs)), (Rep (Vsplatrw $Rs))>;
251-
def: Pat<(VecPI32 (HexagonVSPLATW I32:$Rs)), (Rep (Vsplatrw $Rs))>;
252242
}
253243

254244
class Vneg1<ValueType VecTy>
255-
: PatFrag<(ops), (VecTy (HexagonVSPLATW (i32 -1)))>;
245+
: PatFrag<(ops), (VecTy (HexagonVSPLAT (i32 -1)))>;
256246

257247
class Vnot<ValueType VecTy>
258248
: PatFrag<(ops node:$Vs), (xor $Vs, Vneg1<VecTy>)>;

0 commit comments

Comments
 (0)