diff options
author | Dan Gohman <gohman@apple.com> | 2008-10-21 20:00:42 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-10-21 20:00:42 +0000 |
commit | 7ea1ca6229ca228a1a3a0ff453c3530bf4f7a26e (patch) | |
tree | b47f957c57c01d2f6b8052aed25b8ab6ed84c266 /lib | |
parent | 48534b31d8bc5a68ba152fcdb905bf266def5268 (diff) | |
download | external_llvm-7ea1ca6229ca228a1a3a0ff453c3530bf4f7a26e.zip external_llvm-7ea1ca6229ca228a1a3a0ff453c3530bf4f7a26e.tar.gz external_llvm-7ea1ca6229ca228a1a3a0ff453c3530bf4f7a26e.tar.bz2 |
Fix SelectionDAGBuild lowering of Select instructions to
handle first-class aggregate values. Also, fix a bug in
the Ret handling for empty aggregates.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57925 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index ed9edf1..d04daeb 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -902,11 +902,13 @@ void SelectionDAGLowering::visitRet(ReturnInst &I) { SmallVector<SDValue, 8> NewValues; NewValues.push_back(getControlRoot()); for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) { - SDValue RetOp = getValue(I.getOperand(i)); - SmallVector<MVT, 4> ValueVTs; ComputeValueVTs(TLI, I.getOperand(i)->getType(), ValueVTs); - for (unsigned j = 0, f = ValueVTs.size(); j != f; ++j) { + unsigned NumValues = ValueVTs.size(); + if (NumValues == 0) continue; + + SDValue RetOp = getValue(I.getOperand(i)); + for (unsigned j = 0, f = NumValues; j != f; ++j) { MVT VT = ValueVTs[j]; // FIXME: C calling convention requires the return type to be promoted to @@ -2137,11 +2139,23 @@ void SelectionDAGLowering::visitVFCmp(User &I) { } void SelectionDAGLowering::visitSelect(User &I) { - SDValue Cond = getValue(I.getOperand(0)); - SDValue TrueVal = getValue(I.getOperand(1)); - SDValue FalseVal = getValue(I.getOperand(2)); - setValue(&I, DAG.getNode(ISD::SELECT, TrueVal.getValueType(), Cond, - TrueVal, FalseVal)); + SmallVector<MVT, 4> ValueVTs; + ComputeValueVTs(TLI, I.getType(), ValueVTs); + unsigned NumValues = ValueVTs.size(); + if (NumValues != 0) { + SmallVector<SDValue, 4> Values(NumValues); + SDValue Cond = getValue(I.getOperand(0)); + SDValue TrueVal = getValue(I.getOperand(1)); + SDValue FalseVal = getValue(I.getOperand(2)); + + for (unsigned i = 0; i != NumValues; ++i) + Values[i] = DAG.getNode(ISD::SELECT, TrueVal.getValueType(), Cond, + SDValue(TrueVal.getNode(), TrueVal.getResNo() + i), + SDValue(FalseVal.getNode(), FalseVal.getResNo() + i)); + + setValue(&I, DAG.getMergeValues(DAG.getVTList(&ValueVTs[0], NumValues), + &Values[0], NumValues)); + } } |