[llvm-commits] [llvm] r150247 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp test/Transforms/InstSimplify/compare.ll

Duncan Sands baldrick at free.fr
Fri Feb 10 06:31:25 PST 2012


Author: baldrick
Date: Fri Feb 10 08:31:24 2012
New Revision: 150247

URL: http://llvm.org/viewvc/llvm-project?rev=150247&view=rev
Log:
Fix PR11948: the result type of an icmp may be a vector of boolean -
don't assume it is a boolean.

Modified:
    llvm/trunk/lib/Analysis/InstructionSimplify.cpp
    llvm/trunk/test/Transforms/InstSimplify/compare.ll

Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=150247&r1=150246&r2=150247&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Fri Feb 10 08:31:24 2012
@@ -476,6 +476,11 @@
   // the original comparison.
   if (TCmp == FCmp)
     return TCmp;
+
+  // The remaining cases only make sense if the select condition has the same
+  // type as the result of the comparison, so bail out if this is not so.
+  if (Cond->getType()->isVectorTy() != RHS->getType()->isVectorTy())
+    return 0;
   // If the false value simplified to false, then the result of the compare
   // is equal to "Cond && TCmp".  This also catches the case when the false
   // value simplified to false and the true value to true, returning "Cond".

Modified: llvm/trunk/test/Transforms/InstSimplify/compare.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/compare.ll?rev=150247&r1=150246&r2=150247&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/compare.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/compare.ll Fri Feb 10 08:31:24 2012
@@ -415,3 +415,10 @@
   ret <2 x i1> %c
 ; CHECK: ret <2 x i1> %cond
 }
+
+define <2 x i1> @vectorselectcrash(i32 %arg1) { ; PR11948
+  %tobool40 = icmp ne i32 %arg1, 0
+  %cond43 = select i1 %tobool40, <2 x i16> <i16 -5, i16 66>, <2 x i16> <i16 46, i16 1>
+  %cmp45 = icmp ugt <2 x i16> %cond43, <i16 73, i16 21>
+  ret <2 x i1> %cmp45
+}





More information about the llvm-commits mailing list