-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GlobalISel][X86] G_GEP selection support.
Summary: [GlobalISel][X86] G_GEP selection support. Reviewers: zvi, guyblank Reviewed By: guyblank Subscribers: dberris, rovka, llvm-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D32396 llvm-svn: 302412
- Loading branch information
Igor Breger
committed
May 8, 2017
1 parent
511f0b8
commit 810c625
Showing
6 changed files
with
339 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=x86_64-linux-gnu -global-isel < %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=X64_GISEL | ||
; RUN: llc -mtriple=x86_64-linux-gnu < %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=X64 | ||
|
||
define i32* @test_gep_i8(i32 *%arr, i8 %ind) { | ||
; X64_GISEL-LABEL: test_gep_i8: | ||
; X64_GISEL: # BB#0: | ||
; X64_GISEL-NEXT: movq $4, %rax | ||
; X64_GISEL-NEXT: movsbq %sil, %rcx | ||
; X64_GISEL-NEXT: imulq %rax, %rcx | ||
; X64_GISEL-NEXT: leaq (%rdi,%rcx), %rax | ||
; X64_GISEL-NEXT: retq | ||
; | ||
; X64-LABEL: test_gep_i8: | ||
; X64: # BB#0: | ||
; X64-NEXT: # kill: %ESI<def> %ESI<kill> %RSI<def> | ||
; X64-NEXT: movsbq %sil, %rax | ||
; X64-NEXT: leaq (%rdi,%rax,4), %rax | ||
; X64-NEXT: retq | ||
%arrayidx = getelementptr i32, i32* %arr, i8 %ind | ||
ret i32* %arrayidx | ||
} | ||
|
||
define i32* @test_gep_i8_const(i32 *%arr) { | ||
; X64_GISEL-LABEL: test_gep_i8_const: | ||
; X64_GISEL: # BB#0: | ||
; X64_GISEL-NEXT: movq $80, %rax | ||
; X64_GISEL-NEXT: leaq (%rdi,%rax), %rax | ||
; X64_GISEL-NEXT: retq | ||
; | ||
; X64-LABEL: test_gep_i8_const: | ||
; X64: # BB#0: | ||
; X64-NEXT: leaq 80(%rdi), %rax | ||
; X64-NEXT: retq | ||
%arrayidx = getelementptr i32, i32* %arr, i8 20 | ||
ret i32* %arrayidx | ||
} | ||
|
||
define i32* @test_gep_i16(i32 *%arr, i16 %ind) { | ||
; X64_GISEL-LABEL: test_gep_i16: | ||
; X64_GISEL: # BB#0: | ||
; X64_GISEL-NEXT: movq $4, %rax | ||
; X64_GISEL-NEXT: movswq %si, %rcx | ||
; X64_GISEL-NEXT: imulq %rax, %rcx | ||
; X64_GISEL-NEXT: leaq (%rdi,%rcx), %rax | ||
; X64_GISEL-NEXT: retq | ||
; | ||
; X64-LABEL: test_gep_i16: | ||
; X64: # BB#0: | ||
; X64-NEXT: # kill: %ESI<def> %ESI<kill> %RSI<def> | ||
; X64-NEXT: movswq %si, %rax | ||
; X64-NEXT: leaq (%rdi,%rax,4), %rax | ||
; X64-NEXT: retq | ||
%arrayidx = getelementptr i32, i32* %arr, i16 %ind | ||
ret i32* %arrayidx | ||
} | ||
|
||
define i32* @test_gep_i16_const(i32 *%arr) { | ||
; X64_GISEL-LABEL: test_gep_i16_const: | ||
; X64_GISEL: # BB#0: | ||
; X64_GISEL-NEXT: movq $80, %rax | ||
; X64_GISEL-NEXT: leaq (%rdi,%rax), %rax | ||
; X64_GISEL-NEXT: retq | ||
; | ||
; X64-LABEL: test_gep_i16_const: | ||
; X64: # BB#0: | ||
; X64-NEXT: leaq 80(%rdi), %rax | ||
; X64-NEXT: retq | ||
%arrayidx = getelementptr i32, i32* %arr, i16 20 | ||
ret i32* %arrayidx | ||
} | ||
|
||
define i32* @test_gep_i32(i32 *%arr, i32 %ind) { | ||
; X64_GISEL-LABEL: test_gep_i32: | ||
; X64_GISEL: # BB#0: | ||
; X64_GISEL-NEXT: movq $4, %rax | ||
; X64_GISEL-NEXT: movslq %esi, %rcx | ||
; X64_GISEL-NEXT: imulq %rax, %rcx | ||
; X64_GISEL-NEXT: leaq (%rdi,%rcx), %rax | ||
; X64_GISEL-NEXT: retq | ||
; | ||
; X64-LABEL: test_gep_i32: | ||
; X64: # BB#0: | ||
; X64-NEXT: movslq %esi, %rax | ||
; X64-NEXT: leaq (%rdi,%rax,4), %rax | ||
; X64-NEXT: retq | ||
%arrayidx = getelementptr i32, i32* %arr, i32 %ind | ||
ret i32* %arrayidx | ||
} | ||
|
||
define i32* @test_gep_i32_const(i32 *%arr) { | ||
; X64_GISEL-LABEL: test_gep_i32_const: | ||
; X64_GISEL: # BB#0: | ||
; X64_GISEL-NEXT: movq $20, %rax | ||
; X64_GISEL-NEXT: leaq (%rdi,%rax), %rax | ||
; X64_GISEL-NEXT: retq | ||
; | ||
; X64-LABEL: test_gep_i32_const: | ||
; X64: # BB#0: | ||
; X64-NEXT: leaq 20(%rdi), %rax | ||
; X64-NEXT: retq | ||
%arrayidx = getelementptr i32, i32* %arr, i32 5 | ||
ret i32* %arrayidx | ||
} | ||
|
||
define i32* @test_gep_i64(i32 *%arr, i64 %ind) { | ||
; X64_GISEL-LABEL: test_gep_i64: | ||
; X64_GISEL: # BB#0: | ||
; X64_GISEL-NEXT: movq $4, %rax | ||
; X64_GISEL-NEXT: imulq %rsi, %rax | ||
; X64_GISEL-NEXT: leaq (%rdi,%rax), %rax | ||
; X64_GISEL-NEXT: retq | ||
; | ||
; X64-LABEL: test_gep_i64: | ||
; X64: # BB#0: | ||
; X64-NEXT: leaq (%rdi,%rsi,4), %rax | ||
; X64-NEXT: retq | ||
%arrayidx = getelementptr i32, i32* %arr, i64 %ind | ||
ret i32* %arrayidx | ||
} | ||
|
||
define i32* @test_gep_i64_const(i32 *%arr) { | ||
; X64_GISEL-LABEL: test_gep_i64_const: | ||
; X64_GISEL: # BB#0: | ||
; X64_GISEL-NEXT: movq $20, %rax | ||
; X64_GISEL-NEXT: leaq (%rdi,%rax), %rax | ||
; X64_GISEL-NEXT: retq | ||
; | ||
; X64-LABEL: test_gep_i64_const: | ||
; X64: # BB#0: | ||
; X64-NEXT: leaq 20(%rdi), %rax | ||
; X64-NEXT: retq | ||
%arrayidx = getelementptr i32, i32* %arr, i64 5 | ||
ret i32* %arrayidx | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# RUN: llc -mtriple=x86_64-linux-gnu -global-isel -run-pass=legalizer %s -o - | FileCheck %s | ||
|
||
--- | | ||
define void @test_gep_i8() { | ||
%arrayidx = getelementptr i32, i32* undef, i8 5 | ||
ret void | ||
} | ||
|
||
define void @test_gep_i16() { | ||
%arrayidx = getelementptr i32, i32* undef, i16 5 | ||
ret void | ||
} | ||
|
||
define void @test_gep_i32() { | ||
%arrayidx = getelementptr i32, i32* undef, i32 5 | ||
ret void | ||
} | ||
|
||
define void @test_gep_i64() { | ||
%arrayidx = getelementptr i32, i32* undef, i64 5 | ||
ret void | ||
} | ||
... | ||
--- | ||
name: test_gep_i8 | ||
# CHECK-LABEL: name: test_gep_i8 | ||
legalized: false | ||
registers: | ||
- { id: 0, class: _ } | ||
- { id: 1, class: _ } | ||
- { id: 2, class: _ } | ||
# CHECK: %0(p0) = IMPLICIT_DEF | ||
# CHECK-NEXT: %1(s8) = G_CONSTANT i8 20 | ||
# CHECK-NEXT: %3(s32) = G_SEXT %1(s8) | ||
# CHECK-NEXT: %2(p0) = G_GEP %0, %3(s32) | ||
# CHECK-NEXT: RET 0 | ||
body: | | ||
bb.1 (%ir-block.0): | ||
%0(p0) = IMPLICIT_DEF | ||
%1(s8) = G_CONSTANT i8 20 | ||
%2(p0) = G_GEP %0, %1(s8) | ||
RET 0 | ||
... | ||
--- | ||
name: test_gep_i16 | ||
# CHECK-LABEL: name: test_gep_i16 | ||
legalized: false | ||
registers: | ||
- { id: 0, class: _ } | ||
- { id: 1, class: _ } | ||
- { id: 2, class: _ } | ||
# CHECK: %0(p0) = IMPLICIT_DEF | ||
# CHECK-NEXT: %1(s16) = G_CONSTANT i16 20 | ||
# CHECK-NEXT: %3(s32) = G_SEXT %1(s16) | ||
# CHECK-NEXT: %2(p0) = G_GEP %0, %3(s32) | ||
# CHECK-NEXT: RET 0 | ||
body: | | ||
bb.1 (%ir-block.0): | ||
%0(p0) = IMPLICIT_DEF | ||
%1(s16) = G_CONSTANT i16 20 | ||
%2(p0) = G_GEP %0, %1(s16) | ||
RET 0 | ||
... | ||
--- | ||
name: test_gep_i32 | ||
# CHECK-LABEL: name: test_gep_i32 | ||
legalized: false | ||
registers: | ||
- { id: 0, class: _ } | ||
- { id: 1, class: _ } | ||
- { id: 2, class: _ } | ||
# CHECK: %0(p0) = IMPLICIT_DEF | ||
# CHECK-NEXT: %1(s32) = G_CONSTANT i32 20 | ||
# CHECK-NEXT: %2(p0) = G_GEP %0, %1(s32) | ||
# CHECK-NEXT: RET 0 | ||
body: | | ||
bb.1 (%ir-block.0): | ||
%0(p0) = IMPLICIT_DEF | ||
%1(s32) = G_CONSTANT i32 20 | ||
%2(p0) = G_GEP %0, %1(s32) | ||
RET 0 | ||
... | ||
--- | ||
name: test_gep_i64 | ||
# CHECK-LABEL: name: test_gep_i64 | ||
legalized: false | ||
registers: | ||
- { id: 0, class: _ } | ||
- { id: 1, class: _ } | ||
- { id: 2, class: _ } | ||
# CHECK: %0(p0) = IMPLICIT_DEF | ||
# CHECK-NEXT: %1(s64) = G_CONSTANT i64 20 | ||
# CHECK-NEXT: %2(p0) = G_GEP %0, %1(s64) | ||
# CHECK-NEXT: RET 0 | ||
body: | | ||
bb.1 (%ir-block.0): | ||
%0(p0) = IMPLICIT_DEF | ||
%1(s64) = G_CONSTANT i64 20 | ||
%2(p0) = G_GEP %0, %1(s64) | ||
RET 0 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.