diff options
author | Mon P Wang <wangmp@apple.com> | 2009-04-03 02:43:30 +0000 |
---|---|---|
committer | Mon P Wang <wangmp@apple.com> | 2009-04-03 02:43:30 +0000 |
commit | 9c186c5d27b36d064e8aa9ef7ec3086dda07f8bf (patch) | |
tree | e492f528905f6c42599b1d54873047f1d208d4f8 /llvm/lib | |
parent | 5d7120439079e3b4d1f52f79263dc7e92e379e38 (diff) | |
download | bcm5719-llvm-9c186c5d27b36d064e8aa9ef7ec3086dda07f8bf.tar.gz bcm5719-llvm-9c186c5d27b36d064e8aa9ef7ec3086dda07f8bf.zip |
Added a x86 dag combine to increase the chances to use a
movq for v2i64 on x86-32.
llvm-svn: 68368
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index b9c17f23039..c5a6acbf7af 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -8061,15 +8061,43 @@ static bool EltsFromConsecutiveLoads(SDNode *N, SDValue PermMask, /// PerformShuffleCombine - Combine a vector_shuffle that is equal to /// build_vector load1, load2, load3, load4, <0, 1, 2, 3> into a 128-bit load /// if the load addresses are consecutive, non-overlapping, and in the right -/// order. +/// order. In the case of v2i64, it will see if it can rewrite the +/// shuffle to be an appropriate build vector so it can take advantage of +// performBuildVectorCombine. static SDValue PerformShuffleCombine(SDNode *N, SelectionDAG &DAG, const TargetLowering &TLI) { - MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); DebugLoc dl = N->getDebugLoc(); MVT VT = N->getValueType(0); MVT EVT = VT.getVectorElementType(); SDValue PermMask = N->getOperand(2); unsigned NumElems = PermMask.getNumOperands(); + + // For x86-32 machines, if we see an insert and then a shuffle in a v2i64 + // where the upper half is 0, it is advantageous to rewrite it as a build + // vector of (0, val) so it can use movq. + if (VT == MVT::v2i64) { + SDValue In[2]; + In[0] = N->getOperand(0); + In[1] = N->getOperand(1); + unsigned Idx0 =cast<ConstantSDNode>(PermMask.getOperand(0))->getZExtValue(); + unsigned Idx1 =cast<ConstantSDNode>(PermMask.getOperand(1))->getZExtValue(); + if (In[0].getValueType().getVectorNumElements() == NumElems && + In[Idx0/2].getOpcode() == ISD::INSERT_VECTOR_ELT && + In[Idx1/2].getOpcode() == ISD::BUILD_VECTOR) { + ConstantSDNode* InsertVecIdx = + dyn_cast<ConstantSDNode>(In[Idx0/2].getOperand(2)); + if (InsertVecIdx && + InsertVecIdx->getZExtValue() == (Idx0 % 2) && + isZeroNode(In[Idx1/2].getOperand(Idx1 % 2))) { + return DAG.getNode(ISD::BUILD_VECTOR, dl, VT, + In[Idx0/2].getOperand(1), + In[Idx1/2].getOperand(Idx1 % 2)); + } + } + } + + // Try to combine a vector_shuffle into a 128-bit load. + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); SDNode *Base = NULL; if (!EltsFromConsecutiveLoads(N, PermMask, NumElems, EVT, Base, DAG, MFI, TLI)) |