1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs -o - %s | FileCheck %s
4 # Post-legalizer should not generate illegal extending loads
6 name: zextload_from_inreg
7 tracksRegLiveness: true
12 ; CHECK-LABEL: name: zextload_from_inreg
13 ; CHECK: liveins: $vgpr0_vgpr1
15 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
16 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s64) = G_LOAD [[COPY]](p1) :: (load (s64), addrspace 1)
17 ; CHECK-NEXT: %k:_(s64) = G_CONSTANT i64 4294967295
18 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[LOAD]], %k
19 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY [[AND]](s64)
20 %0:_(p1) = COPY $vgpr0_vgpr1
21 %1:_(s64) = G_LOAD %0 :: (load (s64), align 8, addrspace 1)
22 %k:_(s64) = G_CONSTANT i64 4294967295
23 %2:_(s64) = G_AND %1, %k
24 $vgpr0_vgpr1 = COPY %2
27 # Legal to fold into zextload
29 name: zext_inreg_8_zextload_s32
30 tracksRegLiveness: true
35 ; CHECK-LABEL: name: zext_inreg_8_zextload_s32
36 ; CHECK: liveins: $vgpr0_vgpr1
38 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
39 ; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p1) :: (load (s8), align 4, addrspace 1)
40 ; CHECK-NEXT: $vgpr0 = COPY [[ZEXTLOAD]](s32)
41 %0:_(p1) = COPY $vgpr0_vgpr1
42 %1:_(s32) = G_LOAD %0 :: (load (s32), align 4, addrspace 1)
43 %k:_(s32) = G_CONSTANT i32 255
44 %2:_(s32) = G_AND %1, %k
49 name: zext_inreg_7_zextload_s32
50 tracksRegLiveness: true
55 ; CHECK-LABEL: name: zext_inreg_7_zextload_s32
56 ; CHECK: liveins: $vgpr0_vgpr1
58 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
59 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p1) :: (load (s32), addrspace 1)
60 ; CHECK-NEXT: %k:_(s32) = G_CONSTANT i32 127
61 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[LOAD]], %k
62 ; CHECK-NEXT: $vgpr0 = COPY [[AND]](s32)
63 %0:_(p1) = COPY $vgpr0_vgpr1
64 %1:_(s32) = G_LOAD %0 :: (load (s32), align 4, addrspace 1)
65 %k:_(s32) = G_CONSTANT i32 127
66 %2:_(s32) = G_AND %1, %k
71 name: zext_inreg_9_zextload_s32
72 tracksRegLiveness: true
77 ; CHECK-LABEL: name: zext_inreg_9_zextload_s32
78 ; CHECK: liveins: $vgpr0_vgpr1
80 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
81 ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p1) :: (load (s32), addrspace 1)
82 ; CHECK-NEXT: %k:_(s32) = G_CONSTANT i32 511
83 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[LOAD]], %k
84 ; CHECK-NEXT: $vgpr0 = COPY [[AND]](s32)
85 %0:_(p1) = COPY $vgpr0_vgpr1
86 %1:_(s32) = G_LOAD %0 :: (load (s32), align 4, addrspace 1)
87 %k:_(s32) = G_CONSTANT i32 511
88 %2:_(s32) = G_AND %1, %k
92 # Legal to fold into zextload
94 name: zext_inreg_16_zextload_s32
95 tracksRegLiveness: true
100 ; CHECK-LABEL: name: zext_inreg_16_zextload_s32
101 ; CHECK: liveins: $vgpr0_vgpr1
103 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
104 ; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p1) :: (load (s16), align 4, addrspace 1)
105 ; CHECK-NEXT: $vgpr0 = COPY [[ZEXTLOAD]](s32)
106 %0:_(p1) = COPY $vgpr0_vgpr1
107 %1:_(s32) = G_LOAD %0 :: (load (s32), align 4, addrspace 1)
108 %k:_(s32) = G_CONSTANT i32 65535
109 %2:_(s32) = G_AND %1, %k
114 name: zext_inreg_8_zextload_s8
115 tracksRegLiveness: true
119 liveins: $vgpr0_vgpr1
120 ; CHECK-LABEL: name: zext_inreg_8_zextload_s8
121 ; CHECK: liveins: $vgpr0_vgpr1
123 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
124 ; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
125 ; CHECK-NEXT: $vgpr0 = COPY [[ZEXTLOAD]](s32)
126 %0:_(p1) = COPY $vgpr0_vgpr1
127 %1:_(s32) = G_LOAD %0 :: (load (s8), align 1, addrspace 1)
128 %k:_(s32) = G_CONSTANT i32 255
129 %2:_(s32) = G_AND %1, %k
134 name: zext_inreg_8_zextload_s8_volatile
135 tracksRegLiveness: true
139 liveins: $vgpr0_vgpr1
140 ; CHECK-LABEL: name: zext_inreg_8_zextload_s8_volatile
141 ; CHECK: liveins: $vgpr0_vgpr1
143 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
144 ; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p1) :: (volatile load (s8), addrspace 1)
145 ; CHECK-NEXT: $vgpr0 = COPY [[ZEXTLOAD]](s32)
146 %0:_(p1) = COPY $vgpr0_vgpr1
147 %1:_(s32) = G_LOAD %0 :: (volatile load (s8), align 1, addrspace 1)
148 %k:_(s32) = G_CONSTANT i32 255
149 %2:_(s32) = G_AND %1, %k
154 name: zext_inreg_16_zextload_s16
155 tracksRegLiveness: true
159 liveins: $vgpr0_vgpr1
160 ; CHECK-LABEL: name: zext_inreg_16_zextload_s16
161 ; CHECK: liveins: $vgpr0_vgpr1
163 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
164 ; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p1) :: (load (s16), addrspace 1)
165 ; CHECK-NEXT: $vgpr0 = COPY [[ZEXTLOAD]](s32)
166 %0:_(p1) = COPY $vgpr0_vgpr1
167 %1:_(s32) = G_LOAD %0 :: (load (s16), align 2, addrspace 1)
168 %k:_(s32) = G_CONSTANT i32 65535
169 %2:_(s32) = G_AND %1, %k
174 name: zext_inreg_16_zextload_s16_volatile
175 tracksRegLiveness: true
179 liveins: $vgpr0_vgpr1
180 ; CHECK-LABEL: name: zext_inreg_16_zextload_s16_volatile
181 ; CHECK: liveins: $vgpr0_vgpr1
183 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
184 ; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p1) :: (volatile load (s16), addrspace 1)
185 ; CHECK-NEXT: $vgpr0 = COPY [[ZEXTLOAD]](s32)
186 %0:_(p1) = COPY $vgpr0_vgpr1
187 %1:_(s32) = G_LOAD %0 :: (volatile load (s16), align 2, addrspace 1)
188 %k:_(s32) = G_CONSTANT i32 65535
189 %2:_(s32) = G_AND %1, %k