summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp15
-rw-r--r--llvm/test/Transforms/InstSimplify/implies.ll16
2 files changed, 27 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index c8a13c79f57..8175fbd76d6 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -2129,19 +2129,26 @@ static Constant *computePointerICmp(const DataLayout &DL,
}
/// Return true if B is known to be implied by A. A & B must be i1 (boolean)
-/// values. Note that the truth table for implication is the same as <=u on i1
-/// values (but not <=s!). The truth table for both is:
+/// values or a vector of such values. Note that the truth table for
+/// implication is the same as <=u on i1 values (but not <=s!). The truth
+/// table for both is:
/// | T | F (B)
/// T | T | F
/// F | T | T
/// (A)
static bool implies(Value *A, Value *B) {
- // TODO: Consider extending this to vector of i1?
- assert(A->getType()->isIntegerTy(1) && B->getType()->isIntegerTy(1));
+ assert(A->getType() == B->getType() && "mismatched type");
+ Type *OpTy = A->getType();
+ assert(OpTy->getScalarType()->isIntegerTy(1));
// A ==> A by definition
if (A == B) return true;
+ if (OpTy->isVectorTy())
+ // TODO: extending the code below to handle vectors
+ return false;
+ assert(OpTy->isIntegerTy(1) && "implied by above");
+
ICmpInst::Predicate APred, BPred;
Value *I;
Value *L;
diff --git a/llvm/test/Transforms/InstSimplify/implies.ll b/llvm/test/Transforms/InstSimplify/implies.ll
index 19e61930d75..80b6ac810d0 100644
--- a/llvm/test/Transforms/InstSimplify/implies.ll
+++ b/llvm/test/Transforms/InstSimplify/implies.ll
@@ -75,3 +75,19 @@ define i1 @test4(i32 %length.i, i32 %i) {
%res = icmp ule i1 %var30, %var29
ret i1 %res
}
+
+; A ==> A for vectors
+define <4 x i1> @test5(<4 x i1> %vec) {
+; CHECK-LABEL: @test5
+; CHECK: ret <4 x i1> <i1 true, i1 true, i1 true, i1 true>
+ %res = icmp ule <4 x i1> %vec, %vec
+ ret <4 x i1> %res
+}
+
+; Don't crash on vector inputs - pr25040
+define <4 x i1> @test6(<4 x i1> %a, <4 x i1> %b) {
+; CHECK-LABEL: @test6
+; CHECK: ret <4 x i1> %res
+ %res = icmp ule <4 x i1> %a, %b
+ ret <4 x i1> %res
+}
OpenPOWER on IntegriCloud