[llvm-commits] [llvm] r158166 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineSelect.cpp test/Transforms/InstCombine/2012-6-7-vselect-bitcast.ll
Nadav Rotem
nadav.rotem at intel.com
Thu Jun 7 13:28:57 PDT 2012
Author: nadav
Date: Thu Jun 7 15:28:57 2012
New Revision: 158166
URL: http://llvm.org/viewvc/llvm-project?rev=158166&view=rev
Log:
Fix a bug in FoldSelectOpOp. Bitcast ops may change the number of vector elements, which may disagree with the select condition type.
Added:
llvm/trunk/test/Transforms/InstCombine/2012-6-7-vselect-bitcast.ll
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=158166&r1=158165&r2=158166&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Thu Jun 7 15:28:57 2012
@@ -129,6 +129,12 @@
if (TI->isCast()) {
if (TI->getOperand(0)->getType() != FI->getOperand(0)->getType())
return 0;
+ // The select condition may be a vector. We may only change the operand
+ // type if the vector width remains the same (and matches the condition).
+ Type *CondTy = SI.getCondition()->getType();
+ if (CondTy->isVectorTy() && CondTy->getVectorNumElements() !=
+ FI->getOperand(0)->getType()->getVectorNumElements())
+ return 0;
} else {
return 0; // unknown unary op.
}
Added: llvm/trunk/test/Transforms/InstCombine/2012-6-7-vselect-bitcast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2012-6-7-vselect-bitcast.ll?rev=158166&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2012-6-7-vselect-bitcast.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/2012-6-7-vselect-bitcast.ll Thu Jun 7 15:28:57 2012
@@ -0,0 +1,11 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; CHECK: bitcast
+
+define void @foo(<16 x i8> %a, <16 x i8> %b, <4 x i32>* %c) {
+ %aa = bitcast <16 x i8> %a to <4 x i32>
+ %bb = bitcast <16 x i8> %b to <4 x i32>
+ %select_v = select <4 x i1> zeroinitializer, <4 x i32> %aa, <4 x i32> %bb
+ store <4 x i32> %select_v, <4 x i32>* %c, align 4
+ ret void
+}
+
More information about the llvm-commits
mailing list