Skip to content

Commit 0e2c1cb

Browse files
committed
[X86] ReplaceNodeResults - always attempt to fold TRUNCATE -> PACKSS/PACKUS nodes.
No need to limit this to sub-128-bit cases now that matchTruncateWithPACK handles this.
1 parent 888717e commit 0e2c1cb

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32059,21 +32059,19 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
3205932059
unsigned WidenNumElts = WidenVT.getVectorNumElements();
3206032060
unsigned InBits = InVT.getSizeInBits();
3206132061

32062-
if (128 % InBits == 0) {
32063-
// See if there are sufficient leading bits to perform a PACKUS/PACKSS.
32064-
unsigned PackOpcode;
32065-
if (SDValue Src =
32066-
matchTruncateWithPACK(PackOpcode, VT, In, dl, DAG, Subtarget)) {
32067-
SDValue WidenSrc =
32068-
widenSubVector(Src, false, Subtarget, DAG, dl,
32069-
InEltVT.getSizeInBits() * WidenNumElts);
32070-
if (SDValue Res = truncateVectorWithPACK(PackOpcode, WidenVT, WidenSrc,
32071-
dl, DAG, Subtarget)) {
32072-
Results.push_back(Res);
32073-
return;
32074-
}
32062+
// See if there are sufficient leading bits to perform a PACKUS/PACKSS.
32063+
unsigned PackOpcode;
32064+
if (SDValue Src =
32065+
matchTruncateWithPACK(PackOpcode, VT, In, dl, DAG, Subtarget)) {
32066+
if (SDValue Res = truncateVectorWithPACK(PackOpcode, VT, Src,
32067+
dl, DAG, Subtarget)) {
32068+
Res = widenSubVector(WidenVT, Res, false, Subtarget, DAG, dl);
32069+
Results.push_back(Res);
32070+
return;
3207532071
}
32072+
}
3207632073

32074+
if (128 % InBits == 0) {
3207732075
// 128 bit and smaller inputs should avoid truncate all together and
3207832076
// just use a build_vector that will become a shuffle.
3207932077
// TODO: Widen and use a shuffle directly?

0 commit comments

Comments
 (0)