Skip to content

Commit 9025c26

Browse files
committed
[AArch64] Add an extra test case for adds and subs combines. NFC
1 parent defd0d9 commit 9025c26

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

llvm/test/CodeGen/AArch64/adds_cmn.ll

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=aarch64-linux-gnu -O3 -o - %s | FileCheck %s
3+
4+
define { i32, i32 } @adds_cmn(i32 noundef %x, i32 noundef %y) {
5+
; CHECK-LABEL: adds_cmn:
6+
; CHECK: // %bb.0: // %entry
7+
; CHECK-NEXT: cmn w0, w1
8+
; CHECK-NEXT: add w1, w0, w1
9+
; CHECK-NEXT: cset w8, lo
10+
; CHECK-NEXT: mov w0, w8
11+
; CHECK-NEXT: ret
12+
entry:
13+
%0 = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %x, i32 %y)
14+
%_4.1 = extractvalue { i32, i1 } %0, 1
15+
%_5 = add nuw i32 %x, %y
16+
%_0.sroa.3.0 = select i1 %_4.1, i32 undef, i32 %_5
17+
%not._4.1 = xor i1 %_4.1, true
18+
%_0.sroa.0.0 = zext i1 %not._4.1 to i32
19+
%1 = insertvalue { i32, i32 } poison, i32 %_0.sroa.0.0, 0
20+
%2 = insertvalue { i32, i32 } %1, i32 %_0.sroa.3.0, 1
21+
ret { i32, i32 } %2
22+
}
23+
24+
define { i32, i32 } @adds_cmn_c(i32 noundef %x, i32 noundef %y) {
25+
; CHECK-LABEL: adds_cmn_c:
26+
; CHECK: // %bb.0: // %entry
27+
; CHECK-NEXT: cmn w0, w1
28+
; CHECK-NEXT: add w1, w1, w0
29+
; CHECK-NEXT: cset w8, lo
30+
; CHECK-NEXT: mov w0, w8
31+
; CHECK-NEXT: ret
32+
entry:
33+
%0 = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %x, i32 %y)
34+
%_4.1 = extractvalue { i32, i1 } %0, 1
35+
%_5 = add nuw i32 %y, %x
36+
%_0.sroa.3.0 = select i1 %_4.1, i32 undef, i32 %_5
37+
%not._4.1 = xor i1 %_4.1, true
38+
%_0.sroa.0.0 = zext i1 %not._4.1 to i32
39+
%1 = insertvalue { i32, i32 } poison, i32 %_0.sroa.0.0, 0
40+
%2 = insertvalue { i32, i32 } %1, i32 %_0.sroa.3.0, 1
41+
ret { i32, i32 } %2
42+
}
43+
44+
define { i32, i32 } @subs_cmp(i32 noundef %x, i32 noundef %y) {
45+
; CHECK-LABEL: subs_cmp:
46+
; CHECK: // %bb.0: // %entry
47+
; CHECK-NEXT: subs w1, w0, w1
48+
; CHECK-NEXT: cset w0, hs
49+
; CHECK-NEXT: ret
50+
entry:
51+
%0 = tail call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %x, i32 %y)
52+
%_4.1 = extractvalue { i32, i1 } %0, 1
53+
%_5 = sub nuw i32 %x, %y
54+
%_0.sroa.3.0 = select i1 %_4.1, i32 undef, i32 %_5
55+
%not._4.1 = xor i1 %_4.1, true
56+
%_0.sroa.0.0 = zext i1 %not._4.1 to i32
57+
%1 = insertvalue { i32, i32 } poison, i32 %_0.sroa.0.0, 0
58+
%2 = insertvalue { i32, i32 } %1, i32 %_0.sroa.3.0, 1
59+
ret { i32, i32 } %2
60+
}
61+
62+
define { i32, i32 } @subs_cmp_c(i32 noundef %x, i32 noundef %y) {
63+
; CHECK-LABEL: subs_cmp_c:
64+
; CHECK: // %bb.0: // %entry
65+
; CHECK-NEXT: cmp w0, w1
66+
; CHECK-NEXT: sub w1, w1, w0
67+
; CHECK-NEXT: cset w8, hs
68+
; CHECK-NEXT: mov w0, w8
69+
; CHECK-NEXT: ret
70+
entry:
71+
%0 = tail call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %x, i32 %y)
72+
%_4.1 = extractvalue { i32, i1 } %0, 1
73+
%_5 = sub nuw i32 %y, %x
74+
%_0.sroa.3.0 = select i1 %_4.1, i32 undef, i32 %_5
75+
%not._4.1 = xor i1 %_4.1, true
76+
%_0.sroa.0.0 = zext i1 %not._4.1 to i32
77+
%1 = insertvalue { i32, i32 } poison, i32 %_0.sroa.0.0, 0
78+
%2 = insertvalue { i32, i32 } %1, i32 %_0.sroa.3.0, 1
79+
ret { i32, i32 } %2
80+
}

0 commit comments

Comments
 (0)