diff options
author | Duncan Sands <baldrick@free.fr> | 2012-02-10 14:31:24 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2012-02-10 14:31:24 +0000 |
commit | aa97bb54f02784abefa0ae170af5937915bdb329 (patch) | |
tree | e94fbc877e972fa4b6b4eff8707aef62124186a6 | |
parent | edfb931edbf31f8de132834e064ede723ac74d23 (diff) | |
download | external_llvm-aa97bb54f02784abefa0ae170af5937915bdb329.zip external_llvm-aa97bb54f02784abefa0ae170af5937915bdb329.tar.gz external_llvm-aa97bb54f02784abefa0ae170af5937915bdb329.tar.bz2 |
Fix PR11948: the result type of an icmp may be a vector of boolean -
don't assume it is a boolean.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150247 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/InstructionSimplify.cpp | 5 | ||||
-rw-r--r-- | test/Transforms/InstSimplify/compare.ll | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index bce7e79..7656220 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -476,6 +476,11 @@ static Value *ThreadCmpOverSelect(CmpInst::Predicate Pred, Value *LHS, // 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". diff --git a/test/Transforms/InstSimplify/compare.ll b/test/Transforms/InstSimplify/compare.ll index 1ca2355..0c4153f 100644 --- a/test/Transforms/InstSimplify/compare.ll +++ b/test/Transforms/InstSimplify/compare.ll @@ -415,3 +415,10 @@ define <2 x i1> @vectorselect1(<2 x i1> %cond) { 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 +} |