[llvm-branch-commits] [llvm-branch] r195413 - Merging r195397:
Bill Wendling
isanbard at gmail.com
Thu Nov 21 21:18:08 PST 2013
Author: void
Date: Thu Nov 21 23:18:07 2013
New Revision: 195413
URL: http://llvm.org/viewvc/llvm-project?rev=195413&view=rev
Log:
Merging r195397:
------------------------------------------------------------------------
r195397 | tstellar | 2013-11-21 16:39:23 -0800 (Thu, 21 Nov 2013) | 11 lines
Split SETCC if VSELECT requires splitting too.
This patch is a rewrite of the original patch commited in r194542. Instead of
relying on the type legalizer to do the splitting for us, we now peform the
splitting ourselves in the DAG combiner. This is necessary for the case where
the vector mask is a legal type after promotion and still wouldn't require
splitting.
Patch by: Juergen Ributzka
NOTE: This is a candidate for the 3.4 branch.
------------------------------------------------------------------------
Modified:
llvm/branches/release_34/ (props changed)
llvm/branches/release_34/include/llvm/CodeGen/SelectionDAG.h
llvm/branches/release_34/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/branches/release_34/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
Propchange: llvm/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 21 23:18:07 2013
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,195092-195094,195100,195102-195103,195118,195129,195138,195152,195156-195157,195161-195162,195193,195272,195317-195318,195333,195339,195355
+/llvm/trunk:155241,195092-195094,195100,195102-195103,195118,195129,195138,195152,195156-195157,195161-195162,195193,195272,195317-195318,195333,195339,195355,195397
Modified: llvm/branches/release_34/include/llvm/CodeGen/SelectionDAG.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/include/llvm/CodeGen/SelectionDAG.h?rev=195413&r1=195412&r2=195413&view=diff
==============================================================================
--- llvm/branches/release_34/include/llvm/CodeGen/SelectionDAG.h (original)
+++ llvm/branches/release_34/include/llvm/CodeGen/SelectionDAG.h Thu Nov 21 23:18:07 2013
@@ -1149,7 +1149,8 @@ public:
/// SplitVectorOperand - Split the node's operand with EXTRACT_SUBVECTOR and
/// return the low/high part.
- std::pair<SDValue, SDValue> SplitVectorOperand(SDNode *N, unsigned OpNo) {
+ std::pair<SDValue, SDValue> SplitVectorOperand(const SDNode *N, unsigned OpNo)
+ {
return SplitVector(N->getOperand(OpNo), SDLoc(N));
}
Modified: llvm/branches/release_34/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=195413&r1=195412&r2=195413&view=diff
==============================================================================
--- llvm/branches/release_34/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/branches/release_34/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Nov 21 23:18:07 2013
@@ -4327,6 +4327,23 @@ SDValue DAGCombiner::visitSELECT(SDNode
return SDValue();
}
+static
+std::pair<SDValue, SDValue> SplitVSETCC(const SDNode *N, SelectionDAG &DAG) {
+ SDLoc DL(N);
+ EVT LoVT, HiVT;
+ llvm::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(N->getValueType(0));
+
+ // Split the inputs.
+ SDValue Lo, Hi, LL, LH, RL, RH;
+ llvm::tie(LL, LH) = DAG.SplitVectorOperand(N, 0);
+ llvm::tie(RL, RH) = DAG.SplitVectorOperand(N, 1);
+
+ Lo = DAG.getNode(N->getOpcode(), DL, LoVT, LL, RL, N->getOperand(2));
+ Hi = DAG.getNode(N->getOpcode(), DL, HiVT, LH, RH, N->getOperand(2));
+
+ return std::make_pair(Lo, Hi);
+}
+
SDValue DAGCombiner::visitVSELECT(SDNode *N) {
SDValue N0 = N->getOperand(0);
SDValue N1 = N->getOperand(1);
@@ -4364,27 +4381,32 @@ SDValue DAGCombiner::visitVSELECT(SDNode
}
}
- // Treat SETCC as a vector mask and promote the result type based on the
- // targets expected SETCC result type. This will ensure that SETCC and VSELECT
- // are both split by the type legalizer. This is done to prevent the type
- // legalizer from unrolling SETCC into scalar comparions.
- EVT SelectVT = N->getValueType(0);
- EVT MaskVT = getSetCCResultType(SelectVT);
- assert(MaskVT.isVector() && "Expected a vector type.");
- if (N0.getOpcode() == ISD::SETCC && N0.getValueType() != MaskVT) {
- SDLoc MaskDL(N0);
-
- // Extend the mask to the desired value type.
- ISD::NodeType ExtendCode =
- TargetLowering::getExtendForContent(TLI.getBooleanContents(true));
- SDValue Mask = DAG.getNode(ExtendCode, MaskDL, MaskVT, N0);
-
- AddToWorkList(Mask.getNode());
+ // If the VSELECT result requires splitting and the mask is provided by a
+ // SETCC, then split both nodes and its operands before legalization. This
+ // prevents the type legalizer from unrolling SETCC into scalar comparisons
+ // and enables future optimizations (e.g. min/max pattern matching on X86).
+ if (N0.getOpcode() == ISD::SETCC) {
+ EVT VT = N->getValueType(0);
- SDValue LHS = N->getOperand(1);
- SDValue RHS = N->getOperand(2);
+ // Check if any splitting is required.
+ if (TLI.getTypeAction(*DAG.getContext(), VT) !=
+ TargetLowering::TypeSplitVector)
+ return SDValue();
+
+ SDValue Lo, Hi, CCLo, CCHi, LL, LH, RL, RH;
+ llvm::tie(CCLo, CCHi) = SplitVSETCC(N0.getNode(), DAG);
+ llvm::tie(LL, LH) = DAG.SplitVectorOperand(N, 1);
+ llvm::tie(RL, RH) = DAG.SplitVectorOperand(N, 2);
+
+ Lo = DAG.getNode(N->getOpcode(), DL, LL.getValueType(), CCLo, LL, RL);
+ Hi = DAG.getNode(N->getOpcode(), DL, LH.getValueType(), CCHi, LH, RH);
+
+ // Add the new VSELECT nodes to the work list in case they need to be split
+ // again.
+ AddToWorkList(Lo.getNode());
+ AddToWorkList(Hi.getNode());
- return DAG.getNode(ISD::VSELECT, DL, SelectVT, Mask, LHS, RHS);
+ return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, Lo, Hi);
}
return SDValue();
Modified: llvm/branches/release_34/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp?rev=195413&r1=195412&r2=195413&view=diff
==============================================================================
--- llvm/branches/release_34/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp (original)
+++ llvm/branches/release_34/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Thu Nov 21 23:18:07 2013
@@ -488,11 +488,11 @@ void DAGTypeLegalizer::SplitRes_SELECT(S
SDValue Cond = N->getOperand(0);
CL = CH = Cond;
if (Cond.getValueType().isVector()) {
- if (Cond.getOpcode() == ISD::SETCC) {
- assert(Cond.getValueType() == getSetCCResultType(N->getValueType(0)) &&
- "Condition has not been prepared for split!");
+ // Check if there are already splitted versions of the vector available and
+ // use those instead of splitting the mask operand again.
+ if (getTypeAction(Cond.getValueType()) == TargetLowering::TypeSplitVector)
GetSplitVector(Cond, CL, CH);
- } else
+ else
llvm::tie(CL, CH) = DAG.SplitVector(Cond, dl);
}
More information about the llvm-branch-commits
mailing list