1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: opt -mtriple=aarch64-linux-gnu -passes=typepromotion < %s | llc -mtriple=aarch64-linux-gnu -o - | FileCheck %s
4 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
6 %struct.bar = type { %struct.foo }
7 %struct.foo = type { ptr }
8 %struct.wobble = type { ptr }
9 %struct.zot = type <{ %struct.wobble, ptr, ptr, i8, [7 x i8] }>
11 @global = external global %struct.bar, align 8
13 define i64 @bfis_in_loop_zero() {
14 ; CHECK-LABEL: bfis_in_loop_zero:
15 ; CHECK: // %bb.0: // %entry
16 ; CHECK-NEXT: adrp x8, :got:global
17 ; CHECK-NEXT: mov x0, xzr
18 ; CHECK-NEXT: mov w9, wzr
19 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:global]
20 ; CHECK-NEXT: ldr x8, [x8]
21 ; CHECK-NEXT: .LBB0_1: // %midblock
22 ; CHECK-NEXT: // =>This Inner Loop Header: Depth=1
23 ; CHECK-NEXT: ldrh w10, [x8, #72]
24 ; CHECK-NEXT: ldr x13, [x8, #8]
25 ; CHECK-NEXT: ubfx x11, x10, #8, #24
26 ; CHECK-NEXT: cmp w10, #0
27 ; CHECK-NEXT: and x10, x10, #0xff
28 ; CHECK-NEXT: cset w12, ne
29 ; CHECK-NEXT: ldr x8, [x13, #16]
30 ; CHECK-NEXT: csel w9, w9, w11, eq
31 ; CHECK-NEXT: and x11, x0, #0xffffffff00000000
32 ; CHECK-NEXT: orr x10, x10, x9, lsl #8
33 ; CHECK-NEXT: orr x11, x11, x12, lsl #16
34 ; CHECK-NEXT: orr x0, x11, x10
35 ; CHECK-NEXT: cbnz x13, .LBB0_1
36 ; CHECK-NEXT: // %bb.2: // %exit
39 %var = load ptr, ptr @global, align 8
45 header: ; preds = %bb63, %bb
46 %var4 = phi i64 [ %var30, %latch ], [ 0, %preheader ]
47 %var5 = phi ptr [ %var38, %latch ], [ %var, %preheader ]
48 %var6 = phi i8 [ %var21, %latch ], [ 0, %preheader ]
51 midblock: ; preds = %bb9
52 %var15 = getelementptr inbounds %struct.wobble, ptr %var5, i64 9
53 %var17 = load i16, ptr %var15, align 8
54 %var18 = icmp eq i16 %var17, 0
55 %var19 = lshr i16 %var17, 8
56 %var20 = trunc i16 %var19 to i8
57 %var21 = select i1 %var18, i8 %var6, i8 %var20
58 %var22 = zext i8 %var21 to i16
59 %var23 = shl nuw i16 %var22, 8
60 %var24 = and i16 %var17, 255
61 %var25 = or i16 %var23, %var24
62 %var26 = select i1 %var18, i64 0, i64 65536
63 %var27 = zext i16 %var25 to i64
64 %var28 = and i64 %var4, -4294967296
65 %var29 = or i64 %var26, %var28
66 %var30 = or i64 %var29, %var27
69 latch: ; preds = %bb14, %bb9
70 %var34 = getelementptr inbounds %struct.wobble, ptr %var5, i64 1, i32 0
71 %var35 = load ptr, ptr %var34, align 8
72 %var36 = icmp eq ptr %var35, null
73 %var37 = getelementptr inbounds %struct.zot, ptr %var35, i64 0, i32 2
74 %var38 = load ptr, ptr %var37, align 8
75 br i1 %var36, label %exit, label %header
81 define i64 @bfis_in_loop_undef() {
82 ; CHECK-LABEL: bfis_in_loop_undef:
83 ; CHECK: // %bb.0: // %entry
84 ; CHECK-NEXT: adrp x9, :got:global
85 ; CHECK-NEXT: mov w8, wzr
86 ; CHECK-NEXT: // implicit-def: $x0
87 ; CHECK-NEXT: ldr x9, [x9, :got_lo12:global]
88 ; CHECK-NEXT: ldr x9, [x9]
89 ; CHECK-NEXT: .LBB1_1: // %midblock
90 ; CHECK-NEXT: // =>This Inner Loop Header: Depth=1
91 ; CHECK-NEXT: ldrh w10, [x9, #72]
92 ; CHECK-NEXT: ldr x13, [x9, #8]
93 ; CHECK-NEXT: ubfx x11, x10, #8, #24
94 ; CHECK-NEXT: cmp w10, #0
95 ; CHECK-NEXT: and x10, x10, #0xff
96 ; CHECK-NEXT: cset w12, ne
97 ; CHECK-NEXT: ldr x9, [x13, #16]
98 ; CHECK-NEXT: csel w8, w8, w11, eq
99 ; CHECK-NEXT: and x11, x0, #0xffffffff00000000
100 ; CHECK-NEXT: orr x10, x10, x8, lsl #8
101 ; CHECK-NEXT: orr x11, x11, x12, lsl #16
102 ; CHECK-NEXT: orr x0, x11, x10
103 ; CHECK-NEXT: cbnz x13, .LBB1_1
104 ; CHECK-NEXT: // %bb.2: // %exit
107 %var = load ptr, ptr @global, align 8
113 header: ; preds = %bb63, %bb
114 %var4 = phi i64 [ %var30, %latch ], [ undef, %preheader ]
115 %var5 = phi ptr [ %var38, %latch ], [ %var, %preheader ]
116 %var6 = phi i8 [ %var21, %latch ], [ undef, %preheader ]
119 midblock: ; preds = %bb9
120 %var15 = getelementptr inbounds %struct.wobble, ptr %var5, i64 9
121 %var17 = load i16, ptr %var15, align 8
122 %var18 = icmp eq i16 %var17, 0
123 %var19 = lshr i16 %var17, 8
124 %var20 = trunc i16 %var19 to i8
125 %var21 = select i1 %var18, i8 %var6, i8 %var20
126 %var22 = zext i8 %var21 to i16
127 %var23 = shl nuw i16 %var22, 8
128 %var24 = and i16 %var17, 255
129 %var25 = or i16 %var23, %var24
130 %var26 = select i1 %var18, i64 0, i64 65536
131 %var27 = zext i16 %var25 to i64
132 %var28 = and i64 %var4, -4294967296
133 %var29 = or i64 %var26, %var28
134 %var30 = or i64 %var29, %var27
137 latch: ; preds = %bb14, %bb9
138 %var34 = getelementptr inbounds %struct.wobble, ptr %var5, i64 1, i32 0
139 %var35 = load ptr, ptr %var34, align 8
140 %var36 = icmp eq ptr %var35, null
141 %var37 = getelementptr inbounds %struct.zot, ptr %var35, i64 0, i32 2
142 %var38 = load ptr, ptr %var37, align 8
143 br i1 %var36, label %exit, label %header