ConstantFoldSelectInstruction swapped the operands of the select.

Fix 12592. Patch by Matt Pharr.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155480 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nadav Rotem 2012-04-24 20:18:49 +00:00
parent 2003e03045
commit 80c1ea6f9b
2 changed files with 14 additions and 1 deletions

View File

@ -700,7 +700,7 @@ Constant *llvm::ConstantFoldSelectInstruction(Constant *Cond,
ConstantInt *Cond = dyn_cast<ConstantInt>(CondV->getOperand(i));
if (Cond == 0) break;
Constant *Res = (Cond->getZExtValue() ? V2 : V1)->getAggregateElement(i);
Constant *Res = (Cond->getZExtValue() ? V1 : V2)->getAggregateElement(i);
if (Res == 0) break;
Result.push_back(Res);
}

View File

@ -0,0 +1,13 @@
; RUN: opt -instcombine -S < %s | FileCheck %s
; CHECK: @foo
; CHECK: <i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
define <8 x i32> @foo() nounwind {
entry:
%v1.i = select <8 x i1> <i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>,
<8 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>,
<8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
ret <8 x i32> %v1.i
}