1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64_GISEL
3 ; RUN: llc -mtriple=x86_64-linux-gnu -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64
5 define ptr @test_gep_i8(ptr%arr, i8 %ind) {
6 ; X64_GISEL-LABEL: test_gep_i8:
8 ; X64_GISEL-NEXT: # kill: def $esi killed $esi def $rsi
9 ; X64_GISEL-NEXT: shlq $56, %rsi
10 ; X64_GISEL-NEXT: sarq $56, %rsi
11 ; X64_GISEL-NEXT: imulq $4, %rsi, %rax
12 ; X64_GISEL-NEXT: addq %rdi, %rax
13 ; X64_GISEL-NEXT: retq
15 ; X64-LABEL: test_gep_i8:
17 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
18 ; X64-NEXT: movsbq %sil, %rax
19 ; X64-NEXT: leaq (%rdi,%rax,4), %rax
21 %arrayidx = getelementptr i32, ptr %arr, i8 %ind
25 define ptr @test_gep_i8_const(ptr%arr) {
26 ; X64_GISEL-LABEL: test_gep_i8_const:
28 ; X64_GISEL-NEXT: movl $80, %eax
29 ; X64_GISEL-NEXT: addq %rdi, %rax
30 ; X64_GISEL-NEXT: retq
32 ; X64-LABEL: test_gep_i8_const:
34 ; X64-NEXT: leaq 80(%rdi), %rax
36 %arrayidx = getelementptr i32, ptr %arr, i8 20
40 define ptr @test_gep_i16(ptr%arr, i16 %ind) {
41 ; X64_GISEL-LABEL: test_gep_i16:
43 ; X64_GISEL-NEXT: # kill: def $esi killed $esi def $rsi
44 ; X64_GISEL-NEXT: shlq $48, %rsi
45 ; X64_GISEL-NEXT: sarq $48, %rsi
46 ; X64_GISEL-NEXT: imulq $4, %rsi, %rax
47 ; X64_GISEL-NEXT: addq %rdi, %rax
48 ; X64_GISEL-NEXT: retq
50 ; X64-LABEL: test_gep_i16:
52 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
53 ; X64-NEXT: movswq %si, %rax
54 ; X64-NEXT: leaq (%rdi,%rax,4), %rax
56 %arrayidx = getelementptr i32, ptr %arr, i16 %ind
60 define ptr @test_gep_i16_const(ptr%arr) {
61 ; X64_GISEL-LABEL: test_gep_i16_const:
63 ; X64_GISEL-NEXT: movl $80, %eax
64 ; X64_GISEL-NEXT: addq %rdi, %rax
65 ; X64_GISEL-NEXT: retq
67 ; X64-LABEL: test_gep_i16_const:
69 ; X64-NEXT: leaq 80(%rdi), %rax
71 %arrayidx = getelementptr i32, ptr %arr, i16 20
75 define ptr @test_gep_i32(ptr%arr, i32 %ind) {
76 ; X64_GISEL-LABEL: test_gep_i32:
78 ; X64_GISEL-NEXT: movslq %esi, %rax
79 ; X64_GISEL-NEXT: imulq $4, %rax, %rax
80 ; X64_GISEL-NEXT: addq %rdi, %rax
81 ; X64_GISEL-NEXT: retq
83 ; X64-LABEL: test_gep_i32:
85 ; X64-NEXT: movslq %esi, %rax
86 ; X64-NEXT: leaq (%rdi,%rax,4), %rax
88 %arrayidx = getelementptr i32, ptr %arr, i32 %ind
92 define ptr @test_gep_i32_const(ptr%arr) {
93 ; X64_GISEL-LABEL: test_gep_i32_const:
95 ; X64_GISEL-NEXT: movl $20, %eax
96 ; X64_GISEL-NEXT: addq %rdi, %rax
97 ; X64_GISEL-NEXT: retq
99 ; X64-LABEL: test_gep_i32_const:
101 ; X64-NEXT: leaq 20(%rdi), %rax
103 %arrayidx = getelementptr i32, ptr %arr, i32 5
107 define ptr @test_gep_i64(ptr%arr, i64 %ind) {
108 ; X64_GISEL-LABEL: test_gep_i64:
109 ; X64_GISEL: # %bb.0:
110 ; X64_GISEL-NEXT: imulq $4, %rsi, %rax
111 ; X64_GISEL-NEXT: addq %rdi, %rax
112 ; X64_GISEL-NEXT: retq
114 ; X64-LABEL: test_gep_i64:
116 ; X64-NEXT: leaq (%rdi,%rsi,4), %rax
118 %arrayidx = getelementptr i32, ptr %arr, i64 %ind
122 define ptr @test_gep_i64_const(ptr%arr) {
123 ; X64_GISEL-LABEL: test_gep_i64_const:
124 ; X64_GISEL: # %bb.0:
125 ; X64_GISEL-NEXT: movl $20, %eax
126 ; X64_GISEL-NEXT: addq %rdi, %rax
127 ; X64_GISEL-NEXT: retq
129 ; X64-LABEL: test_gep_i64_const:
131 ; X64-NEXT: leaq 20(%rdi), %rax
133 %arrayidx = getelementptr i32, ptr %arr, i64 5