summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2006-11-10 04:06:59 +0000
committerTanya Lattner <tonic@nondot.org>2006-11-10 04:06:59 +0000
commit2c72a34c497f8221d1806096cac373e853b994b1 (patch)
tree700100390cb2db02ef2f600a8703391c5187e3ac
parentf9fc18995045bf7afcce60621c41fe966d0120fa (diff)
downloadllvm-2c72a34c497f8221d1806096cac373e853b994b1.tar.gz
Merging from mainline
llvm-svn: 31623
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp30
-rw-r--r--llvm/test/Regression/CodeGen/X86/2006-11-12-CSRetCC.ll60
2 files changed, 83 insertions, 7 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index ac7327f9e953..d5b7c1c90e6a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -516,10 +516,9 @@ SDOperand X86TargetLowering::LowerCCCArguments(SDOperand Op, SelectionDAG &DAG)
BytesToPopOnReturn = 0; // Callee pops nothing.
BytesCallerReserves = ArgOffset;
- // If this is a struct return on Darwin/X86, the callee pops the hidden struct
- // pointer.
- if (MF.getFunction()->getCallingConv() == CallingConv::CSRet &&
- Subtarget->isTargetDarwin())
+ // If this is a struct return on, the callee pops the hidden struct
+ // pointer. This is common for Darwin/X86, Linux & Mingw32 targets.
+ if (MF.getFunction()->getCallingConv() == CallingConv::CSRet)
BytesToPopOnReturn = 4;
// Return the new list of results.
@@ -680,9 +679,10 @@ SDOperand X86TargetLowering::LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG) {
// Create the CALLSEQ_END node.
unsigned NumBytesForCalleeToPush = 0;
- // If this is is a call to a struct-return function on Darwin/X86, the callee
+ // If this is is a call to a struct-return function, the callee
// pops the hidden struct pointer, so we have to push it back.
- if (CallingConv == CallingConv::CSRet && Subtarget->isTargetDarwin())
+ // This is common for Darwin/X86, Linux & Mingw32 targets.
+ if (CallingConv == CallingConv::CSRet)
NumBytesForCalleeToPush = 4;
NodeTys.clear();
@@ -2582,6 +2582,22 @@ bool X86::isMOVHLPSMask(SDNode *N) {
isUndefOrEqual(N->getOperand(3), 3);
}
+/// isMOVHLPS_v_undef_Mask - Special case of isMOVHLPSMask for canonical form
+/// of vector_shuffle v, v, <2, 3, 2, 3>, i.e. vector_shuffle v, undef,
+/// <2, 3, 2, 3>
+bool X86::isMOVHLPS_v_undef_Mask(SDNode *N) {
+ assert(N->getOpcode() == ISD::BUILD_VECTOR);
+
+ if (N->getNumOperands() != 4)
+ return false;
+
+ // Expect bit0 == 2, bit1 == 3, bit2 == 2, bit3 == 3
+ return isUndefOrEqual(N->getOperand(0), 2) &&
+ isUndefOrEqual(N->getOperand(1), 3) &&
+ isUndefOrEqual(N->getOperand(2), 2) &&
+ isUndefOrEqual(N->getOperand(3), 3);
+}
+
/// isMOVLPMask - Return true if the specified VECTOR_SHUFFLE operand
/// specifies a shuffle of elements that is suitable for input to MOVLP{S|D}.
bool X86::isMOVLPMask(SDNode *N) {
@@ -3724,7 +3740,7 @@ X86TargetLowering::LowerEXTRACT_VECTOR_ELT(SDOperand Op, SelectionDAG &DAG) {
SDOperand Mask = DAG.getNode(ISD::BUILD_VECTOR, MaskVT,
&IdxVec[0], IdxVec.size());
Vec = DAG.getNode(ISD::VECTOR_SHUFFLE, Vec.getValueType(),
- Vec, Vec, Mask);
+ Vec, DAG.getNode(ISD::UNDEF, Vec.getValueType()), Mask);
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, VT, Vec,
DAG.getConstant(0, getPointerTy()));
} else if (MVT::getSizeInBits(VT) == 64) {
diff --git a/llvm/test/Regression/CodeGen/X86/2006-11-12-CSRetCC.ll b/llvm/test/Regression/CodeGen/X86/2006-11-12-CSRetCC.ll
new file mode 100644
index 000000000000..03be0aca702e
--- /dev/null
+++ b/llvm/test/Regression/CodeGen/X86/2006-11-12-CSRetCC.ll
@@ -0,0 +1,60 @@
+; RUN: llvm-as < %s | llc -march=x86 | grep 'subl $4, %esp'
+
+%str = internal constant [9 x sbyte] c"%f+%f*i\0A\00" ; <[9 x sbyte]*> [#uses=1]
+
+implementation ; Functions:
+
+int %main() {
+entry:
+ %retval = alloca int, align 4 ; <int*> [#uses=1]
+ %tmp = alloca { double, double }, align 16 ; <{ double, double }*> [#uses=4]
+ %tmp1 = alloca { double, double }, align 16 ; <{ double, double }*> [#uses=4]
+ %tmp2 = alloca { double, double }, align 16 ; <{ double, double }*> [#uses=3]
+ %pi = alloca double, align 8 ; <double*> [#uses=2]
+ %z = alloca { double, double }, align 16 ; <{ double, double }*> [#uses=4]
+ "alloca point" = cast int 0 to int ; <int> [#uses=0]
+ store double 0x400921FB54442D18, double* %pi
+ %tmp = load double* %pi ; <double> [#uses=1]
+ %real = getelementptr { double, double }* %tmp1, uint 0, uint 0 ; <double*> [#uses=1]
+ store double 0.000000e+00, double* %real
+ %real3 = getelementptr { double, double }* %tmp1, uint 0, uint 1 ; <double*> [#uses=1]
+ store double %tmp, double* %real3
+ %tmp = getelementptr { double, double }* %tmp, uint 0, uint 0 ; <double*> [#uses=1]
+ %tmp4 = getelementptr { double, double }* %tmp1, uint 0, uint 0 ; <double*> [#uses=1]
+ %tmp5 = load double* %tmp4 ; <double> [#uses=1]
+ store double %tmp5, double* %tmp
+ %tmp6 = getelementptr { double, double }* %tmp, uint 0, uint 1 ; <double*> [#uses=1]
+ %tmp7 = getelementptr { double, double }* %tmp1, uint 0, uint 1 ; <double*> [#uses=1]
+ %tmp8 = load double* %tmp7 ; <double> [#uses=1]
+ store double %tmp8, double* %tmp6
+ %tmp = cast { double, double }* %tmp to { long, long }* ; <{ long, long }*> [#uses=1]
+ %tmp = getelementptr { long, long }* %tmp, uint 0, uint 0 ; <long*> [#uses=1]
+ %tmp = load long* %tmp ; <long> [#uses=1]
+ %tmp9 = cast { double, double }* %tmp to { long, long }* ; <{ long, long }*> [#uses=1]
+ %tmp10 = getelementptr { long, long }* %tmp9, uint 0, uint 1 ; <long*> [#uses=1]
+ %tmp11 = load long* %tmp10 ; <long> [#uses=1]
+ call csretcc void %cexp( { double, double }* %tmp2, long %tmp, long %tmp11 )
+ %tmp12 = getelementptr { double, double }* %z, uint 0, uint 0 ; <double*> [#uses=1]
+ %tmp13 = getelementptr { double, double }* %tmp2, uint 0, uint 0 ; <double*> [#uses=1]
+ %tmp14 = load double* %tmp13 ; <double> [#uses=1]
+ store double %tmp14, double* %tmp12
+ %tmp15 = getelementptr { double, double }* %z, uint 0, uint 1 ; <double*> [#uses=1]
+ %tmp16 = getelementptr { double, double }* %tmp2, uint 0, uint 1 ; <double*> [#uses=1]
+ %tmp17 = load double* %tmp16 ; <double> [#uses=1]
+ store double %tmp17, double* %tmp15
+ %tmp18 = getelementptr { double, double }* %z, uint 0, uint 1 ; <double*> [#uses=1]
+ %tmp19 = load double* %tmp18 ; <double> [#uses=1]
+ %tmp20 = getelementptr { double, double }* %z, uint 0, uint 0 ; <double*> [#uses=1]
+ %tmp21 = load double* %tmp20 ; <double> [#uses=1]
+ %tmp = getelementptr [9 x sbyte]* %str, int 0, uint 0 ; <sbyte*> [#uses=1]
+ %tmp = call int (sbyte*, ...)* %printf( sbyte* %tmp, double %tmp21, double %tmp19 ) ; <int> [#uses=0]
+ br label %return
+
+return: ; preds = %entry
+ %retval = load int* %retval ; <int> [#uses=1]
+ ret int %retval
+}
+
+declare csretcc void %cexp({ double, double }*, long, long)
+
+declare int %printf(sbyte*, ...)