llvm.org GIT mirror llvm / 52098de
Fix pr25040 - Handle vectors of i1s in recently added implication code As mentioned in the bug, I'd missed the presence of a getScalarType in the caller of the new implies method. As a result, when we ended up with a implication over two vectors, we'd trip an assert and crash. Differential Revision: http://reviews.llvm.org/D13441 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249442 91177308-0d34-0410-b5e6-96231b3b80d8 Philip Reames 4 years ago
2 changed file(s) with 27 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
21282128 }
21292129
21302130 /// Return true if B is known to be implied by A. A & B must be i1 (boolean)
2131 /// values. Note that the truth table for implication is the same as <=u on i1
2132 /// values (but not <=s!). The truth table for both is:
2131 /// values or a vector of such values. Note that the truth table for
2132 /// implication is the same as <=u on i1 values (but not <=s!). The truth
2133 /// table for both is:
21332134 /// | T | F (B)
21342135 /// T | T | F
21352136 /// F | T | T
21362137 /// (A)
21372138 static bool implies(Value *A, Value *B) {
2138 // TODO: Consider extending this to vector of i1?
2139 assert(A->getType()->isIntegerTy(1) && B->getType()->isIntegerTy(1));
2139 assert(A->getType() == B->getType() && "mismatched type");
2140 Type *OpTy = A->getType();
2141 assert(OpTy->getScalarType()->isIntegerTy(1));
21402142
21412143 // A ==> A by definition
21422144 if (A == B) return true;
2145
2146 if (OpTy->isVectorTy())
2147 // TODO: extending the code below to handle vectors
2148 return false;
2149 assert(OpTy->isIntegerTy(1) && "implied by above");
21432150
21442151 ICmpInst::Predicate APred, BPred;
21452152 Value *I;
7474 %res = icmp ule i1 %var30, %var29
7575 ret i1 %res
7676 }
77
78 ; A ==> A for vectors
79 define <4 x i1> @test5(<4 x i1> %vec) {
80 ; CHECK-LABEL: @test5
81 ; CHECK: ret <4 x i1>
82 %res = icmp ule <4 x i1> %vec, %vec
83 ret <4 x i1> %res
84 }
85
86 ; Don't crash on vector inputs - pr25040
87 define <4 x i1> @test6(<4 x i1> %a, <4 x i1> %b) {
88 ; CHECK-LABEL: @test6
89 ; CHECK: ret <4 x i1> %res
90 %res = icmp ule <4 x i1> %a, %b
91 ret <4 x i1> %res
92 }