Skip to content

Commit 55a9c79

Browse files
committed
[X86][SSE] Merge SSE2 PINSRW lowering with SSE41 PINSRB/PINSRW lowering. NFCI.
These are identical apart from the extra SSE41 guard for PINSRB. llvm-svn: 293766
1 parent 7a5ec55 commit 55a9c79

File tree

1 file changed

+21
-32
lines changed

1 file changed

+21
-32
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13921,25 +13921,27 @@ SDValue X86TargetLowering::LowerINSERT_VECTOR_ELT(SDValue Op,
1392113921
}
1392213922
assert(VT.is128BitVector() && "Only 128-bit vector types should be left!");
1392313923

13924-
if (Subtarget.hasSSE41()) {
13925-
if (EltVT.getSizeInBits() == 8 || EltVT.getSizeInBits() == 16) {
13926-
unsigned Opc;
13927-
if (VT == MVT::v8i16) {
13928-
Opc = X86ISD::PINSRW;
13929-
} else {
13930-
assert(VT == MVT::v16i8);
13931-
Opc = X86ISD::PINSRB;
13932-
}
13933-
13934-
// Transform it so it match pinsr{b,w} which expects a GR32 as its second
13935-
// argument.
13936-
if (N1.getValueType() != MVT::i32)
13937-
N1 = DAG.getNode(ISD::ANY_EXTEND, dl, MVT::i32, N1);
13938-
if (N2.getValueType() != MVT::i32)
13939-
N2 = DAG.getIntPtrConstant(IdxVal, dl);
13940-
return DAG.getNode(Opc, dl, VT, N0, N1, N2);
13924+
// Transform it so it match pinsr{b,w} which expects a GR32 as its second
13925+
// argument. SSE41 required for pinsrb.
13926+
if (VT == MVT::v8i16 || (VT == MVT::v16i8 && Subtarget.hasSSE41())) {
13927+
unsigned Opc;
13928+
if (VT == MVT::v8i16) {
13929+
assert(Subtarget.hasSSE2() && "SSE2 required for PINSRW");
13930+
Opc = X86ISD::PINSRW;
13931+
} else {
13932+
assert(VT == MVT::v16i8 && "PINSRB requires v16i8 vector");
13933+
assert(Subtarget.hasSSE41() && "SSE41 required for PINSRB");
13934+
Opc = X86ISD::PINSRB;
1394113935
}
1394213936

13937+
if (N1.getValueType() != MVT::i32)
13938+
N1 = DAG.getNode(ISD::ANY_EXTEND, dl, MVT::i32, N1);
13939+
if (N2.getValueType() != MVT::i32)
13940+
N2 = DAG.getIntPtrConstant(IdxVal, dl);
13941+
return DAG.getNode(Opc, dl, VT, N0, N1, N2);
13942+
}
13943+
13944+
if (Subtarget.hasSSE41()) {
1394313945
if (EltVT == MVT::f32) {
1394413946
// Bits [7:6] of the constant are the source select. This will always be
1394513947
// zero here. The DAG Combiner may combine an extract_elt index into
@@ -13969,24 +13971,11 @@ SDValue X86TargetLowering::LowerINSERT_VECTOR_ELT(SDValue Op,
1396913971
return DAG.getNode(X86ISD::INSERTPS, dl, VT, N0, N1, N2);
1397013972
}
1397113973

13972-
if (EltVT == MVT::i32 || EltVT == MVT::i64) {
13973-
// PINSR* works with constant index.
13974+
// PINSR* works with constant index.
13975+
if (EltVT == MVT::i32 || EltVT == MVT::i64)
1397413976
return Op;
13975-
}
1397613977
}
1397713978

13978-
if (EltVT == MVT::i8)
13979-
return SDValue();
13980-
13981-
if (EltVT.getSizeInBits() == 16) {
13982-
// Transform it so it match pinsrw which expects a 16-bit value in a GR32
13983-
// as its second argument.
13984-
if (N1.getValueType() != MVT::i32)
13985-
N1 = DAG.getNode(ISD::ANY_EXTEND, dl, MVT::i32, N1);
13986-
if (N2.getValueType() != MVT::i32)
13987-
N2 = DAG.getIntPtrConstant(IdxVal, dl);
13988-
return DAG.getNode(X86ISD::PINSRW, dl, VT, N0, N1, N2);
13989-
}
1399013979
return SDValue();
1399113980
}
1399213981

0 commit comments

Comments
 (0)