[llvm] r249442 - Fix pr25040 - Handle vectors of i1s in recently added implication code
Arnaud A. de Grandmaison via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 6 12:10:59 PDT 2015
Thanks Philip !
> -----Original Message-----
> From: llvm-commits [mailto:llvm-commits-bounces at lists.llvm.org] On Behalf
> Of Philip Reames via llvm-commits
> Sent: 06 October 2015 21:00
> To: llvm-commits at lists.llvm.org
> Subject: [llvm] r249442 - Fix pr25040 - Handle vectors of i1s in recently added
> implication code
>
> Author: reames
> Date: Tue Oct 6 14:00:02 2015
> New Revision: 249442
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249442&view=rev
> Log:
> 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
>
>
>
> Modified:
> llvm/trunk/lib/Analysis/InstructionSimplify.cpp
> llvm/trunk/test/Transforms/InstSimplify/implies.ll
>
> Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=249442&r1=2494
> 41&r2=249442&view=diff
> ==========================================================
> ====================
> --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
> +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Tue Oct 6 14:00:02
> +++ 2015
> @@ -2129,19 +2129,26 @@ static Constant *computePointerICmp(cons }
>
> /// 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;
>
> Modified: llvm/trunk/test/Transforms/InstSimplify/implies.ll
> URL: http://llvm.org/viewvc/llvm-
> project/llvm/trunk/test/Transforms/InstSimplify/implies.ll?rev=249442&r1=2
> 49441&r2=249442&view=diff
> ==========================================================
> ====================
> --- llvm/trunk/test/Transforms/InstSimplify/implies.ll (original)
> +++ llvm/trunk/test/Transforms/InstSimplify/implies.ll Tue Oct 6
> +++ 14:00:02 2015
> @@ -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
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list