Add support to codegen for getresult instructions with undef operands.
authorDan Gohman <gohman@apple.com>
Wed, 23 Apr 2008 20:21:29 +0000 (20:21 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 23 Apr 2008 20:21:29 +0000 (20:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50180 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
test/CodeGen/Generic/getresult-undef.ll [new file with mode: 0644]

index c9b334fc22c84925f0791622d52bf20b0c740097..7e7a2f41193dbffba6e054087d301713b1ed0a55 100644 (file)
@@ -3311,8 +3311,13 @@ void SelectionDAGLowering::visitCall(CallInst &I) {
 
 
 void SelectionDAGLowering::visitGetResult(GetResultInst &I) {
-  SDOperand Call = getValue(I.getOperand(0));
-  setValue(&I, SDOperand(Call.Val, I.getIndex()));
+  if (UndefValue *UV = dyn_cast<UndefValue>(I.getOperand(0))) {
+    SDOperand Undef = DAG.getNode(ISD::UNDEF, TLI.getValueType(I.getType()));
+    setValue(&I, Undef);
+  } else {
+    SDOperand Call = getValue(I.getOperand(0));
+    setValue(&I, SDOperand(Call.Val, I.getIndex()));
+  }
 }
 
 
diff --git a/test/CodeGen/Generic/getresult-undef.ll b/test/CodeGen/Generic/getresult-undef.ll
new file mode 100644 (file)
index 0000000..7905ff5
--- /dev/null
@@ -0,0 +1,6 @@
+; RUN: llvm-as < %s | llc
+
+define double @foo() {
+  %t = getresult {double, double} undef, 1
+  ret double %t
+}