Skip to content

Commit ac4c46d

Browse files
committed
[InstCombine] add tests for increment-of-ashr; NFC
1 parent 4a1b119 commit ac4c46d

File tree

1 file changed

+57
-0
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+57
-0
lines changed

llvm/test/Transforms/InstCombine/add.ll

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,3 +1897,60 @@ define i8 @not_mul_use2(i8 %x) {
18971897
%plusx = add i8 %not, %x
18981898
ret i8 %plusx
18991899
}
1900+
1901+
define i8 @full_ashr_inc(i8 %x) {
1902+
; CHECK-LABEL: @full_ashr_inc(
1903+
; CHECK-NEXT: [[A:%.*]] = ashr i8 [[X:%.*]], 7
1904+
; CHECK-NEXT: [[R:%.*]] = add nsw i8 [[A]], 1
1905+
; CHECK-NEXT: ret i8 [[R]]
1906+
;
1907+
%a = ashr i8 %x, 7
1908+
%r = add i8 %a, 1
1909+
ret i8 %r
1910+
}
1911+
1912+
define <2 x i6> @full_ashr_inc_vec(<2 x i6> %x) {
1913+
; CHECK-LABEL: @full_ashr_inc_vec(
1914+
; CHECK-NEXT: [[A:%.*]] = ashr <2 x i6> [[X:%.*]], <i6 5, i6 poison>
1915+
; CHECK-NEXT: [[R:%.*]] = add <2 x i6> [[A]], <i6 1, i6 1>
1916+
; CHECK-NEXT: ret <2 x i6> [[R]]
1917+
;
1918+
%a = ashr <2 x i6> %x, <i6 5, i6 poison>
1919+
%r = add <2 x i6> %a, <i6 1, i6 1>
1920+
ret <2 x i6> %r
1921+
}
1922+
1923+
define i8 @full_ashr_inc_use(i8 %x) {
1924+
; CHECK-LABEL: @full_ashr_inc_use(
1925+
; CHECK-NEXT: [[A:%.*]] = ashr i8 [[X:%.*]], 7
1926+
; CHECK-NEXT: call void @use(i8 [[A]])
1927+
; CHECK-NEXT: [[R:%.*]] = add nsw i8 [[A]], 1
1928+
; CHECK-NEXT: ret i8 [[R]]
1929+
;
1930+
%a = ashr i8 %x, 7
1931+
call void @use(i8 %a)
1932+
%r = add i8 %a, 1
1933+
ret i8 %r
1934+
}
1935+
1936+
define i8 @not_full_ashr_inc(i8 %x) {
1937+
; CHECK-LABEL: @not_full_ashr_inc(
1938+
; CHECK-NEXT: [[A:%.*]] = ashr i8 [[X:%.*]], 6
1939+
; CHECK-NEXT: [[R:%.*]] = add nsw i8 [[A]], 1
1940+
; CHECK-NEXT: ret i8 [[R]]
1941+
;
1942+
%a = ashr i8 %x, 6
1943+
%r = add i8 %a, 1
1944+
ret i8 %r
1945+
}
1946+
1947+
define i8 @full_ashr_not_inc(i8 %x) {
1948+
; CHECK-LABEL: @full_ashr_not_inc(
1949+
; CHECK-NEXT: [[A:%.*]] = ashr i8 [[X:%.*]], 7
1950+
; CHECK-NEXT: [[R:%.*]] = add nsw i8 [[A]], 2
1951+
; CHECK-NEXT: ret i8 [[R]]
1952+
;
1953+
%a = ashr i8 %x, 7
1954+
%r = add i8 %a, 2
1955+
ret i8 %r
1956+
}

0 commit comments

Comments
 (0)