1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -o - %s -mtriple=aarch64 | FileCheck %s --check-prefix=CHECK-O2
3 ; RUN: llc -o - %s -mtriple=aarch64 -O3 | FileCheck %s --check-prefix=CHECK-O3
5 %struct.S = type { i32, i16 }
6 define i32 @needless_promotion(ptr nocapture noundef readonly %S, i64 noundef %red_cost) {
7 ; CHECK-O2-LABEL: needless_promotion:
8 ; CHECK-O2: // %bb.0: // %entry
9 ; CHECK-O2-NEXT: ldrsh w8, [x0, #4]
10 ; CHECK-O2-NEXT: tbnz w8, #31, .LBB0_3
11 ; CHECK-O2-NEXT: // %bb.1: // %lor.rhs
12 ; CHECK-O2-NEXT: cbz x1, .LBB0_5
13 ; CHECK-O2-NEXT: // %bb.2:
14 ; CHECK-O2-NEXT: mov w9, #2
15 ; CHECK-O2-NEXT: b .LBB0_4
16 ; CHECK-O2-NEXT: .LBB0_3:
17 ; CHECK-O2-NEXT: mov w9, #1
18 ; CHECK-O2-NEXT: .LBB0_4: // %lor.end.sink.split
19 ; CHECK-O2-NEXT: cmp w8, w9
20 ; CHECK-O2-NEXT: cset w0, eq
22 ; CHECK-O2-NEXT: .LBB0_5:
23 ; CHECK-O2-NEXT: mov w0, wzr
26 ; CHECK-O3-LABEL: needless_promotion:
27 ; CHECK-O3: // %bb.0: // %entry
28 ; CHECK-O3-NEXT: ldrsh w8, [x0, #4]
29 ; CHECK-O3-NEXT: tbnz w8, #31, .LBB0_3
30 ; CHECK-O3-NEXT: // %bb.1: // %lor.rhs
31 ; CHECK-O3-NEXT: cbz x1, .LBB0_4
32 ; CHECK-O3-NEXT: // %bb.2:
33 ; CHECK-O3-NEXT: mov w9, #2
34 ; CHECK-O3-NEXT: cmp w8, w9
35 ; CHECK-O3-NEXT: cset w0, eq
37 ; CHECK-O3-NEXT: .LBB0_3:
38 ; CHECK-O3-NEXT: mov w9, #1
39 ; CHECK-O3-NEXT: cmp w8, w9
40 ; CHECK-O3-NEXT: cset w0, eq
42 ; CHECK-O3-NEXT: .LBB0_4:
43 ; CHECK-O3-NEXT: mov w0, wzr
46 %ident = getelementptr inbounds %struct.S, ptr %S, i64 0, i32 1
47 %0 = load i16, ptr %ident, align 8
48 %cmp = icmp slt i16 %0, 0
49 br i1 %cmp, label %lor.end.sink.split, label %lor.rhs
51 lor.rhs: ; preds = %entry
52 %cmp3.not = icmp eq i64 %red_cost, 0
53 br i1 %cmp3.not, label %lor.end, label %lor.end.sink.split
55 lor.end.sink.split: ; preds = %lor.rhs, %entry
56 %.sink12 = phi i16 [ 1, %entry ], [ 2, %lor.rhs ]
57 %cmp1 = icmp eq i16 %0, %.sink12
58 %phi.cast = zext i1 %cmp1 to i32
61 lor.end: ; preds = %lor.end.sink.split, %lor.rhs
62 %.shrunk = phi i32 [ 0, %lor.rhs ], [ %phi.cast, %lor.end.sink.split ]
66 define i8 @loopcmp(ptr nocapture noundef readonly %x, i8 noundef %y) {
67 ; CHECK-O2-LABEL: loopcmp:
68 ; CHECK-O2: // %bb.0: // %entry
69 ; CHECK-O2-NEXT: and w9, w1, #0xff
70 ; CHECK-O2-NEXT: .LBB1_1: // %while.cond
71 ; CHECK-O2-NEXT: // =>This Inner Loop Header: Depth=1
72 ; CHECK-O2-NEXT: ldrb w8, [x0], #1
73 ; CHECK-O2-NEXT: cmp w8, w9
74 ; CHECK-O2-NEXT: b.lo .LBB1_1
75 ; CHECK-O2-NEXT: // %bb.2: // %while.end
76 ; CHECK-O2-NEXT: mov w0, w8
79 ; CHECK-O3-LABEL: loopcmp:
80 ; CHECK-O3: // %bb.0: // %entry
81 ; CHECK-O3-NEXT: and w9, w1, #0xff
82 ; CHECK-O3-NEXT: .LBB1_1: // %while.cond
83 ; CHECK-O3-NEXT: // =>This Inner Loop Header: Depth=1
84 ; CHECK-O3-NEXT: ldrb w8, [x0], #1
85 ; CHECK-O3-NEXT: cmp w8, w9
86 ; CHECK-O3-NEXT: b.lo .LBB1_1
87 ; CHECK-O3-NEXT: // %bb.2: // %while.end
88 ; CHECK-O3-NEXT: mov w0, w8
93 while.cond: ; preds = %while.cond, %entry
94 %a.0.in = phi ptr [ %x, %entry ], [ %x.addr.0, %while.cond ]
95 %a.0 = load i8, ptr %a.0.in, align 1
96 %cmp = icmp ult i8 %a.0, %y
97 %x.addr.0 = getelementptr inbounds i8, ptr %a.0.in, i64 1
98 br i1 %cmp, label %while.cond, label %while.end
100 while.end: ; preds = %while.cond