[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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294487 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjay Patel 2017-02-08 17:37:17 +00:00
parent 7d1045f0d4
commit bddd84197f
2 changed files with 23 additions and 10 deletions

View File

@ -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
}

View File

@ -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