[llvm] r294487 - [InstCombine] add test for missed vector icmp fold; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 8 09:37:17 PST 2017
Author: spatel
Date: Wed Feb 8 11:37:17 2017
New Revision: 294487
URL: http://llvm.org/viewvc/llvm-project?rev=294487&view=rev
Log:
[InstCombine] add test for missed vector icmp fold; NFC
Also, move the related existing scalar test to a renamed file
where I'm planning to add more icmp-add tests.
Added:
llvm/trunk/test/Transforms/InstCombine/icmp-add.ll
- copied, changed from r294486, llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll
Removed:
llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll
Modified:
llvm/trunk/test/Transforms/InstCombine/icmp.ll
Removed: llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll?rev=294486&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll (removed)
@@ -1,85 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instcombine -S | FileCheck %s
-
-; PR1949
-
-define i1 @test1(i32 %a) {
-; CHECK-LABEL: @test1(
-; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 %a, -5
-; CHECK-NEXT: ret i1 [[C]]
-;
- %b = add i32 %a, 4
- %c = icmp ult i32 %b, 4
- ret i1 %c
-}
-
-define <2 x i1> @test1vec(<2 x i32> %a) {
-; CHECK-LABEL: @test1vec(
-; CHECK-NEXT: [[C:%.*]] = icmp ugt <2 x i32> %a, <i32 -5, i32 -5>
-; CHECK-NEXT: ret <2 x i1> [[C]]
-;
- %b = add <2 x i32> %a, <i32 4, i32 4>
- %c = icmp ult <2 x i32> %b, <i32 4, i32 4>
- ret <2 x i1> %c
-}
-
-define i1 @test2(i32 %a) {
-; CHECK-LABEL: @test2(
-; CHECK-NEXT: [[C:%.*]] = icmp ult i32 %a, 4
-; CHECK-NEXT: ret i1 [[C]]
-;
- %b = sub i32 %a, 4
- %c = icmp ugt i32 %b, -5
- ret i1 %c
-}
-
-define <2 x i1> @test2vec(<2 x i32> %a) {
-; CHECK-LABEL: @test2vec(
-; CHECK-NEXT: [[C:%.*]] = icmp ult <2 x i32> %a, <i32 4, i32 4>
-; CHECK-NEXT: ret <2 x i1> [[C]]
-;
- %b = sub <2 x i32> %a, <i32 4, i32 4>
- %c = icmp ugt <2 x i32> %b, <i32 -5, i32 -5>
- ret <2 x i1> %c
-}
-
-define i1 @test3(i32 %a) {
-; CHECK-LABEL: @test3(
-; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 %a, 2147483643
-; CHECK-NEXT: ret i1 [[C]]
-;
- %b = add i32 %a, 4
- %c = icmp slt i32 %b, 2147483652
- ret i1 %c
-}
-
-define <2 x i1> @test3vec(<2 x i32> %a) {
-; CHECK-LABEL: @test3vec(
-; CHECK-NEXT: [[C:%.*]] = icmp sgt <2 x i32> %a, <i32 2147483643, i32 2147483643>
-; CHECK-NEXT: ret <2 x i1> [[C]]
-;
- %b = add <2 x i32> %a, <i32 4, i32 4>
- %c = icmp slt <2 x i32> %b, <i32 2147483652, i32 2147483652>
- ret <2 x i1> %c
-}
-
-define i1 @test4(i32 %a) {
-; CHECK-LABEL: @test4(
-; CHECK-NEXT: [[C:%.*]] = icmp slt i32 %a, -4
-; CHECK-NEXT: ret i1 [[C]]
-;
- %b = add i32 %a, 2147483652
- %c = icmp sge i32 %b, 4
- ret i1 %c
-}
-
-define <2 x i1> @test4vec(<2 x i32> %a) {
-; CHECK-LABEL: @test4vec(
-; CHECK-NEXT: [[C:%.*]] = icmp slt <2 x i32> %a, <i32 -4, i32 -4>
-; CHECK-NEXT: ret <2 x i1> [[C]]
-;
- %b = add <2 x i32> %a, <i32 2147483652, i32 2147483652>
- %c = icmp sge <2 x i32> %b, <i32 4, i32 4>
- ret <2 x i1> %c
-}
-
Copied: llvm/trunk/test/Transforms/InstCombine/icmp-add.ll (from r294486, llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp-add.ll?p2=llvm/trunk/test/Transforms/InstCombine/icmp-add.ll&p1=llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll&r1=294486&r2=294487&rev=294487&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/icmp-add.ll Wed Feb 8 11:37:17 2017
@@ -83,3 +83,26 @@ define <2 x i1> @test4vec(<2 x i32> %a)
ret <2 x i1> %c
}
+define i1 @slt_zero_add_nsw(i32 %a) {
+; CHECK-LABEL: @slt_zero_add_nsw(
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 %a, -1
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %add = add nsw i32 %a, 1
+ %cmp = icmp slt i32 %add, 0
+ ret i1 %cmp
+}
+
+; FIXME: The same fold should work with vectors.
+
+define <2 x i1> @slt_zero_add_nsw_splat_vec(<2 x i8> %a) {
+; CHECK-LABEL: @slt_zero_add_nsw_splat_vec(
+; CHECK-NEXT: [[ADD:%.*]] = add nsw <2 x i8> %a, <i8 1, i8 1>
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[ADD]], zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[CMP]]
+;
+ %add = add nsw <2 x i8> %a, <i8 1, i8 1>
+ %cmp = icmp slt <2 x i8> %add, zeroinitializer
+ ret <2 x i1> %cmp
+}
+
Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=294487&r1=294486&r2=294487&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Wed Feb 8 11:37:17 2017
@@ -2231,16 +2231,6 @@ define i1 @icmp_sge_zero_add_nsw(i32 %a)
ret i1 %cmp
}
-define i1 @icmp_slt_zero_add_nsw(i32 %a) {
-; CHECK-LABEL: @icmp_slt_zero_add_nsw(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 %a, -1
-; CHECK-NEXT: ret i1 [[CMP]]
-;
- %add = add nsw i32 %a, 1
- %cmp = icmp slt i32 %add, 0
- ret i1 %cmp
-}
-
define i1 @icmp_sle_zero_add_nsw(i32 %a) {
; CHECK-LABEL: @icmp_sle_zero_add_nsw(
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 %a, 0
More information about the llvm-commits
mailing list