1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=x86_64-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefixes=CHECK,X64
3 # RUN: llc -mtriple=i386-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefixes=CHECK,X86
6 define void @test_gep_i8c(ptr %addr) {
7 %arrayidx = getelementptr i32, ptr undef, i8 5
10 define void @test_gep_i8(ptr %addr, i8 %ofs) {
11 %arrayidx = getelementptr i32, ptr undef, i8 %ofs
15 define void @test_gep_i16c(ptr %addr) {
16 %arrayidx = getelementptr i32, ptr undef, i16 5
19 define void @test_gep_i16(ptr %addr, i16 %ofs) {
20 %arrayidx = getelementptr i32, ptr undef, i16 %ofs
24 define void @test_gep_i32c(ptr %addr) {
25 %arrayidx = getelementptr i32, ptr undef, i32 5
28 define void @test_gep_i32(ptr %addr, i32 %ofs) {
29 %arrayidx = getelementptr i32, ptr undef, i32 %ofs
33 define void @test_gep_i64c(ptr %addr) {
34 %arrayidx = getelementptr i32, ptr undef, i64 5
37 define void @test_gep_i64(ptr %addr, i64 %ofs) {
38 %arrayidx = getelementptr i32, ptr undef, i64 %ofs
51 ; CHECK-LABEL: name: test_gep_i8c
52 ; CHECK: [[DEF:%[0-9]+]]:_(p0) = IMPLICIT_DEF
53 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 20
54 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[DEF]], [[C]](s32)
55 ; CHECK-NEXT: G_STORE [[PTR_ADD]](p0), [[DEF]](p0) :: (store (p0) into %ir.addr)
58 %1(s8) = G_CONSTANT i8 20
59 %2(p0) = G_PTR_ADD %0, %1(s8)
60 G_STORE %2, %0 :: (store (p0) into %ir.addr)
72 ; CHECK-LABEL: name: test_gep_i8
73 ; CHECK: [[DEF:%[0-9]+]]:_(p0) = IMPLICIT_DEF
74 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:_(s8) = IMPLICIT_DEF
75 ; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[DEF1]](s8)
76 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[DEF]], [[SEXT]](s32)
77 ; CHECK-NEXT: G_STORE [[PTR_ADD]](p0), [[DEF]](p0) :: (store (p0) into %ir.addr)
81 %2(p0) = G_PTR_ADD %0, %1(s8)
82 G_STORE %2, %0 :: (store (p0) into %ir.addr)
94 ; CHECK-LABEL: name: test_gep_i16c
95 ; CHECK: [[DEF:%[0-9]+]]:_(p0) = IMPLICIT_DEF
96 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 20
97 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[DEF]], [[C]](s32)
98 ; CHECK-NEXT: G_STORE [[PTR_ADD]](p0), [[DEF]](p0) :: (store (p0) into %ir.addr)
100 %0(p0) = IMPLICIT_DEF
101 %1(s16) = G_CONSTANT i16 20
102 %2(p0) = G_PTR_ADD %0, %1(s16)
103 G_STORE %2, %0 :: (store (p0) into %ir.addr)
110 - { id: 0, class: _ }
111 - { id: 1, class: _ }
112 - { id: 2, class: _ }
115 ; CHECK-LABEL: name: test_gep_i16
116 ; CHECK: [[DEF:%[0-9]+]]:_(p0) = IMPLICIT_DEF
117 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:_(s16) = IMPLICIT_DEF
118 ; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[DEF1]](s16)
119 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[DEF]], [[SEXT]](s32)
120 ; CHECK-NEXT: G_STORE [[PTR_ADD]](p0), [[DEF]](p0) :: (store (p0) into %ir.addr)
122 %0(p0) = IMPLICIT_DEF
123 %1(s16) = IMPLICIT_DEF
124 %2(p0) = G_PTR_ADD %0, %1(s16)
125 G_STORE %2, %0 :: (store (p0) into %ir.addr)
132 - { id: 0, class: _ }
133 - { id: 1, class: _ }
134 - { id: 2, class: _ }
137 ; CHECK-LABEL: name: test_gep_i32c
138 ; CHECK: [[DEF:%[0-9]+]]:_(p0) = IMPLICIT_DEF
139 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 20
140 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[DEF]], [[C]](s32)
141 ; CHECK-NEXT: G_STORE [[PTR_ADD]](p0), [[DEF]](p0) :: (store (p0) into %ir.addr)
143 %0(p0) = IMPLICIT_DEF
144 %1(s32) = G_CONSTANT i32 20
145 %2(p0) = G_PTR_ADD %0, %1(s32)
146 G_STORE %2, %0 :: (store (p0) into %ir.addr)
153 - { id: 0, class: _ }
154 - { id: 1, class: _ }
155 - { id: 2, class: _ }
158 ; CHECK-LABEL: name: test_gep_i32
159 ; CHECK: [[DEF:%[0-9]+]]:_(p0) = IMPLICIT_DEF
160 ; CHECK-NEXT: [[DEF1:%[0-9]+]]:_(s32) = IMPLICIT_DEF
161 ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[DEF]], [[DEF1]](s32)
162 ; CHECK-NEXT: G_STORE [[PTR_ADD]](p0), [[DEF]](p0) :: (store (p0) into %ir.addr)
164 %0(p0) = IMPLICIT_DEF
165 %1(s32) = IMPLICIT_DEF
166 %2(p0) = G_PTR_ADD %0, %1(s32)
167 G_STORE %2, %0 :: (store (p0) into %ir.addr)
174 - { id: 0, class: _ }
175 - { id: 1, class: _ }
176 - { id: 2, class: _ }
179 ; X64-LABEL: name: test_gep_i64c
180 ; X64: [[DEF:%[0-9]+]]:_(p0) = IMPLICIT_DEF
181 ; X64-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 20
182 ; X64-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[DEF]], [[C]](s64)
183 ; X64-NEXT: G_STORE [[PTR_ADD]](p0), [[DEF]](p0) :: (store (p0) into %ir.addr)
185 ; X86-LABEL: name: test_gep_i64c
186 ; X86: [[DEF:%[0-9]+]]:_(p0) = IMPLICIT_DEF
187 ; X86-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 20
188 ; X86-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[DEF]], [[C]](s32)
189 ; X86-NEXT: G_STORE [[PTR_ADD]](p0), [[DEF]](p0) :: (store (p0) into %ir.addr)
191 %0(p0) = IMPLICIT_DEF
192 %1(s64) = G_CONSTANT i64 20
193 %2(p0) = G_PTR_ADD %0, %1(s64)
194 G_STORE %2, %0 :: (store (p0) into %ir.addr)
201 - { id: 0, class: _ }
202 - { id: 1, class: _ }
203 - { id: 2, class: _ }
206 ; X64-LABEL: name: test_gep_i64
207 ; X64: [[DEF:%[0-9]+]]:_(p0) = IMPLICIT_DEF
208 ; X64-NEXT: [[DEF1:%[0-9]+]]:_(s64) = IMPLICIT_DEF
209 ; X64-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[DEF]], [[DEF1]](s64)
210 ; X64-NEXT: G_STORE [[PTR_ADD]](p0), [[DEF]](p0) :: (store (p0) into %ir.addr)
212 ; X86-LABEL: name: test_gep_i64
213 ; X86: [[DEF:%[0-9]+]]:_(p0) = IMPLICIT_DEF
214 ; X86-NEXT: [[DEF1:%[0-9]+]]:_(s64) = IMPLICIT_DEF
215 ; X86-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[DEF1]](s64)
216 ; X86-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[DEF]], [[TRUNC]](s32)
217 ; X86-NEXT: G_STORE [[PTR_ADD]](p0), [[DEF]](p0) :: (store (p0) into %ir.addr)
219 %0(p0) = IMPLICIT_DEF
220 %1(s64) = IMPLICIT_DEF
221 %2(p0) = G_PTR_ADD %0, %1(s64)
222 G_STORE %2, %0 :: (store (p0) into %ir.addr)