Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 6e4fb35

Browse files
committed
[X86][SSE] Canonicalize scalar fp arithmetic shuffle patterns
As discussed on PR38197, this canonicalizes MOVS*(N0, OP(N0, N1)) --> MOVS*(N0, SCALAR_TO_VECTOR(OP(N0[0], N1[0]))) This returns the scalar-fp codegen lost by rL336971. Additionally it handles the OP(N1, N0)) case for commutable (FADD/FMUL) ops. Differential Revision: https://reviews.llvm.org/D49474 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337419 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 5aa954c commit 6e4fb35

File tree

2 files changed

+227
-534
lines changed

2 files changed

+227
-534
lines changed

lib/Target/X86/X86ISelLowering.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30698,8 +30698,37 @@ static SDValue combineTargetShuffle(SDValue N, SelectionDAG &DAG,
3069830698
}
3069930699
case X86ISD::MOVSD:
3070030700
case X86ISD::MOVSS: {
30701-
SDValue V0 = peekThroughBitcasts(N->getOperand(0));
30702-
SDValue V1 = peekThroughBitcasts(N->getOperand(1));
30701+
SDValue N0 = N.getOperand(0);
30702+
SDValue N1 = N.getOperand(1);
30703+
30704+
// Canonicalize scalar FPOps:
30705+
// MOVS*(N0, OP(N0, N1)) --> MOVS*(N0, SCALAR_TO_VECTOR(OP(N0[0], N1[0])))
30706+
// If commutable, allow OP(N1[0], N0[0]).
30707+
unsigned Opcode1 = N1.getOpcode();
30708+
if (Opcode1 == ISD::FADD || Opcode1 == ISD::FMUL || Opcode1 == ISD::FSUB ||
30709+
Opcode1 == ISD::FDIV) {
30710+
SDValue N10 = N1.getOperand(0);
30711+
SDValue N11 = N1.getOperand(1);
30712+
if (N10 == N0 ||
30713+
(N11 == N0 && (Opcode1 == ISD::FADD || Opcode1 == ISD::FMUL))) {
30714+
if (N10 != N0)
30715+
std::swap(N10, N11);
30716+
MVT SVT = VT.getVectorElementType();
30717+
SDValue ZeroIdx = DAG.getIntPtrConstant(0, DL);
30718+
N10 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, SVT, N10, ZeroIdx);
30719+
N11 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, SVT, N11, ZeroIdx);
30720+
SDValue Scl = DAG.getNode(Opcode1, DL, SVT, N10, N11);
30721+
SDValue SclVec = DAG.getNode(ISD::SCALAR_TO_VECTOR, DL, VT, Scl);
30722+
DCI.AddToWorklist(N10.getNode());
30723+
DCI.AddToWorklist(N11.getNode());
30724+
DCI.AddToWorklist(Scl.getNode());
30725+
DCI.AddToWorklist(SclVec.getNode());
30726+
return DAG.getNode(Opcode, DL, VT, N0, SclVec);
30727+
}
30728+
}
30729+
30730+
SDValue V0 = peekThroughBitcasts(N0);
30731+
SDValue V1 = peekThroughBitcasts(N1);
3070330732
bool isZero0 = ISD::isBuildVectorAllZeros(V0.getNode());
3070430733
bool isZero1 = ISD::isBuildVectorAllZeros(V1.getNode());
3070530734
if (isZero0 && isZero1)

0 commit comments

Comments
 (0)