Fix the result type of SELECT nodes lowered from Select instructions with
authorDan Gohman <gohman@apple.com>
Fri, 11 Dec 2009 19:50:50 +0000 (19:50 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 11 Dec 2009 19:50:50 +0000 (19:50 +0000)
aggregate return values. This fixes PR5754.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91145 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
test/CodeGen/X86/select-aggregate.ll [new file with mode: 0644]

index 57d89036a8089fadc146a6e8092efdf86af256b4..2a8b57c7ba57cac29487ec460cfd7d5386802ae2 100644 (file)
@@ -2108,7 +2108,7 @@ void SelectionDAGBuilder::visitSelect(User &I) {
 
     for (unsigned i = 0; i != NumValues; ++i)
       Values[i] = DAG.getNode(ISD::SELECT, getCurDebugLoc(),
-                              TrueVal.getValueType(), Cond,
+                              TrueVal.getNode()->getValueType(i), Cond,
                               SDValue(TrueVal.getNode(), TrueVal.getResNo() + i),
                               SDValue(FalseVal.getNode(), FalseVal.getResNo() + i));
 
diff --git a/test/CodeGen/X86/select-aggregate.ll b/test/CodeGen/X86/select-aggregate.ll
new file mode 100644 (file)
index 0000000..fba6a59
--- /dev/null
@@ -0,0 +1,15 @@
+; RUN: llc < %s -march=x86-64 | FileCheck %s
+; PR5754
+
+; CHECK: cmovne %rdi, %rsi
+; CHECK: movl (%rsi), %eax
+
+%0 = type { i64, i32 }
+
+define i32 @foo(%0* %p, %0* %q, i1 %r) nounwind {
+  %t0 = load %0* %p
+  %t1 = load %0* %q
+  %t4 = select i1 %r, %0 %t0, %0 %t1
+  %t5 = extractvalue %0 %t4, 1
+  ret i32 %t5
+}