[llvm] r271810 - [InstCombine] allow vector constants for cast+icmp fold
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 4 15:47:37 PDT 2016
On Sat, Jun 4, 2016 at 3:04 PM, Sanjay Patel via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: spatel
> Date: Sat Jun 4 17:04:05 2016
> New Revision: 271810
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271810&view=rev
> Log:
> [InstCombine] allow vector constants for cast+icmp fold
>
> This is step 1 of unknown towards fixing PR28001:
> https://llvm.org/bugs/show_bug.cgi?id=28001
>
>
> Modified:
> llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> llvm/trunk/test/Transforms/InstCombine/cast.ll
> llvm/trunk/test/Transforms/InstCombine/signed-comparison.ll
>
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=271810&r1=271809&r2=271810&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Sat Jun
> 4 17:04:05 2016
> @@ -2439,7 +2439,7 @@ Instruction *InstCombiner::visitICmpInst
> }
>
> // If we aren't dealing with a constant on the RHS, exit early.
> - auto *CI = dyn_cast<ConstantInt>(ICI.getOperand(1));
> + auto *CI = dyn_cast<Constant>(ICI.getOperand(1));
> if (!CI)
> return nullptr;
>
In InstCombine, variables named `CI` are typically `ConstantInt`. I'd
suggest renaming `CI` to `C`.
>
>
> Modified: llvm/trunk/test/Transforms/InstCombine/cast.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast.ll?rev=271810&r1=271809&r2=271810&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/Transforms/InstCombine/cast.ll (original)
> +++ llvm/trunk/test/Transforms/InstCombine/cast.ll Sat Jun 4 17:04:05 2016
> @@ -214,12 +214,9 @@ define i1 @test19(i32 %X) {
> ret i1 %Z
> }
>
> -; FIXME: Vector should be the same as scalar.
> -
> define <2 x i1> @test19vec(<2 x i32> %X) {
> ; CHECK-LABEL: @test19vec(
> -; CHECK-NEXT: [[C:%.*]] = sext <2 x i32> %X to <2 x i64>
> -; CHECK-NEXT: [[Z:%.*]] = icmp slt <2 x i64> [[C]], <i64 12345, i64
> 2147483647>
> +; CHECK-NEXT: [[Z:%.*]] = icmp slt <2 x i32> %X, <i32 12345, i32
> 2147483647>
> ; CHECK-NEXT: ret <2 x i1> [[Z]]
> ;
> %c = sext <2 x i32> %X to <2 x i64>
> @@ -227,6 +224,16 @@ define <2 x i1> @test19vec(<2 x i32> %X)
> ret <2 x i1> %Z
> }
>
> +define <3 x i1> @test19vec2(<3 x i1> %X) {
> +; CHECK-LABEL: @test19vec2(
> +; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq <3 x i1> %X, zeroinitializer
> +; CHECK-NEXT: ret <3 x i1> [[CMPEQ]]
> +;
> + %sext = sext <3 x i1> %X to <3 x i32>
> + %cmpeq = icmp eq <3 x i32> %sext, zeroinitializer
> + ret <3 x i1> %cmpeq
> +}
> +
> define i1 @test20(i1 %B) {
> ; CHECK-LABEL: @test20(
> ; CHECK-NEXT: ret i1 false
>
> Modified: llvm/trunk/test/Transforms/InstCombine/signed-comparison.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/signed-comparison.ll?rev=271810&r1=271809&r2=271810&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/Transforms/InstCombine/signed-comparison.ll (original)
> +++ llvm/trunk/test/Transforms/InstCombine/signed-comparison.ll Sat Jun 4
> 17:04:05 2016
> @@ -13,12 +13,9 @@ define i1 @scalar_zext_slt(i16 %t4) {
> ret i1 %t6
> }
>
> -; FIXME: Vector compare should work the same as scalar.
> -
> define <4 x i1> @vector_zext_slt(<4 x i16> %t4) {
> ; CHECK-LABEL: @vector_zext_slt(
> -; CHECK-NEXT: [[T5:%.*]] = zext <4 x i16> %t4 to <4 x i32>
> -; CHECK-NEXT: [[T6:%.*]] = icmp ult <4 x i32> [[T5]], <i32 500, i32 0,
> i32 501, i32 65535>
> +; CHECK-NEXT: [[T6:%.*]] = icmp ult <4 x i16> %t4, <i16 500, i16 0,
> i16 501, i16 -1>
> ; CHECK-NEXT: ret <4 x i1> [[T6]]
> ;
> %t5 = zext <4 x i16> %t4 to <4 x i32>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160604/32c28c4b/attachment.html>
More information about the llvm-commits
mailing list