[llvm] r327649 - [X86] Simplify the type legality checking for (FM)ADDSUB/SUBADD matching. NFCI
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 15 10:39:00 PDT 2018
Author: ctopper
Date: Thu Mar 15 10:38:59 2018
New Revision: 327649
URL: http://llvm.org/viewvc/llvm-project?rev=327649&view=rev
Log:
[X86] Simplify the type legality checking for (FM)ADDSUB/SUBADD matching. NFCI
Rather than enumerating all specific types, for the DAG combine we can just use TLI::isTypeLegal and an SSE3 check. For the BUILD_VECTOR version we already know the type is legal so we just need to check SSE3.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=327649&r1=327648&r2=327649&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Mar 15 10:38:59 2018
@@ -7515,9 +7515,7 @@ static bool isAddSubOrSubAdd(const Build
bool matchSubAdd) {
MVT VT = BV->getSimpleValueType(0);
- if ((!Subtarget.hasSSE3() || (VT != MVT::v4f32 && VT != MVT::v2f64)) &&
- (!Subtarget.hasAVX() || (VT != MVT::v8f32 && VT != MVT::v4f64)) &&
- (!Subtarget.hasAVX512() || (VT != MVT::v16f32 && VT != MVT::v8f64)))
+ if (!Subtarget.hasSSE3() || !VT.isFloatingPoint())
return false;
unsigned NumElts = VT.getVectorNumElements();
@@ -30456,13 +30454,13 @@ static SDValue combineTargetShuffle(SDVa
/// by this operation to try to flow through the rest of the combiner
/// the fact that they're unused.
static bool isAddSubOrSubAdd(SDNode *N, const X86Subtarget &Subtarget,
- SDValue &Opnd0, SDValue &Opnd1,
+ SelectionDAG &DAG, SDValue &Opnd0, SDValue &Opnd1,
bool matchSubAdd) {
EVT VT = N->getValueType(0);
- if ((!Subtarget.hasSSE3() || (VT != MVT::v4f32 && VT != MVT::v2f64)) &&
- (!Subtarget.hasAVX() || (VT != MVT::v8f32 && VT != MVT::v4f64)) &&
- (!Subtarget.useAVX512Regs() || (VT != MVT::v16f32 && VT != MVT::v8f64)))
+ const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+ if (!Subtarget.hasSSE3() || !TLI.isTypeLegal(VT) ||
+ !VT.getSimpleVT().isFloatingPoint())
return false;
// We only handle target-independent shuffles.
@@ -30521,7 +30519,7 @@ static SDValue combineShuffleToAddSubOrF
const X86Subtarget &Subtarget,
SelectionDAG &DAG) {
SDValue Opnd0, Opnd1;
- if (!isAddSubOrSubAdd(N, Subtarget, Opnd0, Opnd1, /*matchSubAdd*/false))
+ if (!isAddSubOrSubAdd(N, Subtarget, DAG, Opnd0, Opnd1, /*matchSubAdd*/false))
return SDValue();
MVT VT = N->getSimpleValueType(0);
@@ -30547,7 +30545,7 @@ static SDValue combineShuffleToFMSubAdd(
const X86Subtarget &Subtarget,
SelectionDAG &DAG) {
SDValue Opnd0, Opnd1;
- if (!isAddSubOrSubAdd(N, Subtarget, Opnd0, Opnd1, /*matchSubAdd*/true))
+ if (!isAddSubOrSubAdd(N, Subtarget, DAG, Opnd0, Opnd1, /*matchSubAdd*/true))
return SDValue();
MVT VT = N->getSimpleValueType(0);
More information about the llvm-commits
mailing list