[InstCombine] add tests for increment-of-ashr; NFC

This commit is contained in:
Sanjay Patel 2022-08-29 07:51:36 -04:00
parent 4a1b119658
commit ac4c46d24b
1 changed files with 57 additions and 0 deletions

View File

@ -1897,3 +1897,60 @@ define i8 @not_mul_use2(i8 %x) {
%plusx = add i8 %not, %x
ret i8 %plusx
}
define i8 @full_ashr_inc(i8 %x) {
; CHECK-LABEL: @full_ashr_inc(
; CHECK-NEXT: [[A:%.*]] = ashr i8 [[X:%.*]], 7
; CHECK-NEXT: [[R:%.*]] = add nsw i8 [[A]], 1
; CHECK-NEXT: ret i8 [[R]]
;
%a = ashr i8 %x, 7
%r = add i8 %a, 1
ret i8 %r
}
define <2 x i6> @full_ashr_inc_vec(<2 x i6> %x) {
; CHECK-LABEL: @full_ashr_inc_vec(
; CHECK-NEXT: [[A:%.*]] = ashr <2 x i6> [[X:%.*]], <i6 5, i6 poison>
; CHECK-NEXT: [[R:%.*]] = add <2 x i6> [[A]], <i6 1, i6 1>
; CHECK-NEXT: ret <2 x i6> [[R]]
;
%a = ashr <2 x i6> %x, <i6 5, i6 poison>
%r = add <2 x i6> %a, <i6 1, i6 1>
ret <2 x i6> %r
}
define i8 @full_ashr_inc_use(i8 %x) {
; CHECK-LABEL: @full_ashr_inc_use(
; CHECK-NEXT: [[A:%.*]] = ashr i8 [[X:%.*]], 7
; CHECK-NEXT: call void @use(i8 [[A]])
; CHECK-NEXT: [[R:%.*]] = add nsw i8 [[A]], 1
; CHECK-NEXT: ret i8 [[R]]
;
%a = ashr i8 %x, 7
call void @use(i8 %a)
%r = add i8 %a, 1
ret i8 %r
}
define i8 @not_full_ashr_inc(i8 %x) {
; CHECK-LABEL: @not_full_ashr_inc(
; CHECK-NEXT: [[A:%.*]] = ashr i8 [[X:%.*]], 6
; CHECK-NEXT: [[R:%.*]] = add nsw i8 [[A]], 1
; CHECK-NEXT: ret i8 [[R]]
;
%a = ashr i8 %x, 6
%r = add i8 %a, 1
ret i8 %r
}
define i8 @full_ashr_not_inc(i8 %x) {
; CHECK-LABEL: @full_ashr_not_inc(
; CHECK-NEXT: [[A:%.*]] = ashr i8 [[X:%.*]], 7
; CHECK-NEXT: [[R:%.*]] = add nsw i8 [[A]], 2
; CHECK-NEXT: ret i8 [[R]]
;
%a = ashr i8 %x, 7
%r = add i8 %a, 2
ret i8 %r
}