From 80c1ea6f9baedf7e957e1c26f960792f016b5329 Mon Sep 17 00:00:00 2001 From: Nadav Rotem Date: Tue, 24 Apr 2012 20:18:49 +0000 Subject: 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 --- lib/VMCore/ConstantFold.cpp | 2 +- test/Transforms/InstCombine/2012-04-24-vselect.ll | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/Transforms/InstCombine/2012-04-24-vselect.ll diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index b743287adf3..9b1c756b7de 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -700,7 +700,7 @@ Constant *llvm::ConstantFoldSelectInstruction(Constant *Cond, ConstantInt *Cond = dyn_cast(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/test/Transforms/InstCombine/2012-04-24-vselect.ll b/test/Transforms/InstCombine/2012-04-24-vselect.ll new file mode 100644 index 00000000000..8d2de2b2431 --- /dev/null +++ b/test/Transforms/InstCombine/2012-04-24-vselect.ll @@ -0,0 +1,13 @@ +; RUN: opt -instcombine -S < %s | FileCheck %s + +; CHECK: @foo +; CHECK: + +define <8 x i32> @foo() nounwind { +entry: + %v1.i = select <8 x i1> , + <8 x i32> , + <8 x i32> + ret <8 x i32> %v1.i +} + -- cgit v1.2.3