summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNadav Rotem <nadav.rotem@intel.com>2012-04-24 20:18:49 +0000
committerNadav Rotem <nadav.rotem@intel.com>2012-04-24 20:18:49 +0000
commit450d69a5eed4ed1be26d7a64be66106e665b4f37 (patch)
tree6a44f623810f3e73ae2c5711e9219c99e40219b9
parentd50c3b2c5726fd700b7b632810cbe98282625186 (diff)
downloadbcm5719-llvm-450d69a5eed4ed1be26d7a64be66106e665b4f37.tar.gz
bcm5719-llvm-450d69a5eed4ed1be26d7a64be66106e665b4f37.zip
ConstantFoldSelectInstruction swapped the operands of the select.
Fix 12592. Patch by Matt Pharr. llvm-svn: 155480
-rw-r--r--llvm/lib/VMCore/ConstantFold.cpp2
-rw-r--r--llvm/test/Transforms/InstCombine/2012-04-24-vselect.ll13
2 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp
index b743287adf3..9b1c756b7de 100644
--- a/llvm/lib/VMCore/ConstantFold.cpp
+++ b/llvm/lib/VMCore/ConstantFold.cpp
@@ -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);
}
diff --git a/llvm/test/Transforms/InstCombine/2012-04-24-vselect.ll b/llvm/test/Transforms/InstCombine/2012-04-24-vselect.ll
new file mode 100644
index 00000000000..8d2de2b2431
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/2012-04-24-vselect.ll
@@ -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
+}
+
OpenPOWER on IntegriCloud