From b3e87b2262087cf69f7461e4bc586cdb747434f7 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 12 Mar 2010 07:15:36 +0000 Subject: [PATCH] fix PR6577, a bug in sdbuilder lowering select instructions whose true value was not Val#0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98336 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 3 ++- test/CodeGen/X86/crash.ll | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index ae5474d8d49..f4d3c34e68d 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -2185,7 +2185,8 @@ void SelectionDAGBuilder::visitSelect(User &I) { for (unsigned i = 0; i != NumValues; ++i) Values[i] = DAG.getNode(ISD::SELECT, getCurDebugLoc(), - TrueVal.getNode()->getValueType(i), Cond, + TrueVal.getNode()->getValueType(TrueVal.getResNo()+i), + Cond, SDValue(TrueVal.getNode(), TrueVal.getResNo() + i), SDValue(FalseVal.getNode(), diff --git a/test/CodeGen/X86/crash.ll b/test/CodeGen/X86/crash.ll index b9037f35929..08f59add2bc 100644 --- a/test/CodeGen/X86/crash.ll +++ b/test/CodeGen/X86/crash.ll @@ -33,3 +33,17 @@ if.then: ; preds = %land.end if.end: ; preds = %land.end ret void } + +; PR6577 +%pair = type { i64, double } + +define void @on4() { +dependentGraph243.exit: + %subject19 = load %pair* undef ; <%1> [#uses=1] + %0 = extractvalue %pair %subject19, 1 ; [#uses=2] + %1 = select i1 undef, double %0, double undef ; [#uses=1] + %2 = select i1 undef, double %1, double %0 ; [#uses=1] + %3 = insertvalue %pair undef, double %2, 1 ; <%1> [#uses=1] + store %pair %3, %pair* undef + ret void +} -- 2.34.1