Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[X86][test] Improve global address offset folding tests
- Loading branch information
Showing
2 changed files
with
100 additions
and
66 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,30 +1,105 @@ | ||
; RUN: llc < %s | FileCheck %s | ||
; RUN: llc -mtriple=x86_64 -relocation-model=static < %s | FileCheck --check-prefixes=CHECK,STATIC %s | ||
; RUN: llc -mtriple=x86_64 -relocation-model=pic < %s | FileCheck --check-prefixes=CHECK,PIC %s | ||
; RUN: llc -mtriple=x86_64 -code-model=medium -relocation-model=static < %s | FileCheck --check-prefixes=CHECK,MSTATIC %s | ||
; RUN: llc -mtriple=x86_64 -code-model=medium -relocation-model=pic < %s | FileCheck --check-prefixes=CHECK,MPIC %s | ||
|
||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" | ||
target triple = "x86_64-apple-darwin9.6" | ||
@prev_length = internal global i32 0 ; <i32*> [#uses=1] | ||
@window = internal global [65536 x i8] zeroinitializer, align 32 ; <[65536 x i8]*> [#uses=1] | ||
@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 (i32)* @longest_match to i8*)] ; <[1 x i8*]*> [#uses=0] | ||
@foo = internal global i32 0 | ||
|
||
define fastcc i32 @longest_match(i32 %cur_match) nounwind { | ||
; CHECK-LABEL: longest_match: | ||
; CHECK-NOT: ret | ||
; CHECK: cmpb $0, (%r{{.*}},%r{{.*}}) | ||
; CHECK: ret | ||
define dso_local i64 @zero() #0 { | ||
; CHECK-LABEL: zero: | ||
; CHECK: # %bb.0: | ||
; STATIC-NEXT: movl $foo, %eax | ||
; STATIC-NEXT: retq | ||
; PIC-NEXT: leaq foo(%rip), %rax | ||
; PIC-NEXT: retq | ||
; MSTATIC-NEXT: movabsq $foo, %rax | ||
; MSTATIC-NEXT: retq | ||
; MPIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx | ||
; MPIC-NEXT: movabsq $foo@GOTOFF, %rax | ||
; MPIC-NEXT: addq %rcx, %rax | ||
entry: | ||
ret i64 add (i64 ptrtoint (i32* @foo to i64), i64 0) | ||
} | ||
|
||
define dso_local i64 @one() #0 { | ||
; CHECK-LABEL: one: | ||
; CHECK: # %bb.0: | ||
; STATIC-NEXT: movl $foo+1, %eax | ||
; PIC-NEXT: leaq foo+1(%rip), %rax | ||
; MSTATIC-NEXT: movabsq $foo, %rax | ||
; MSTATIC-NEXT: incq %rax | ||
; MPIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax | ||
; MPIC-NEXT: movabsq $foo@GOTOFF, %rcx | ||
; MPIC-NEXT: leaq 1(%rax,%rcx), %rax | ||
entry: | ||
ret i64 add (i64 ptrtoint (i32* @foo to i64), i64 1) | ||
} | ||
|
||
;; Check we don't fold a large offset into leaq, otherwise | ||
;; the large r_addend can easily cause a relocation overflow. | ||
define dso_local i64 @large() #0 { | ||
; CHECK-LABEL: large: | ||
; CHECK: # %bb.0: | ||
; STATIC-NEXT: movl $1701208431, %eax | ||
; STATIC-NEXT: leaq foo(%rax), %rax | ||
; PIC-NEXT: leaq foo(%rip), %rax | ||
; PIC-NEXT: addq $1701208431, %rax | ||
; MSTATIC-NEXT: movabsq $foo, %rax | ||
; MSTATIC-NEXT: addq $1701208431, %rax | ||
; MSTATIC-NEXT: retq | ||
; MPIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax | ||
; MPIC-NEXT: movabsq $foo@GOTOFF, %rcx | ||
; MPIC-NEXT: leaq 1701208431(%rax,%rcx), %rax | ||
entry: | ||
ret i64 add (i64 ptrtoint (i32* @foo to i64), i64 1701208431) | ||
} | ||
|
||
define dso_local i64 @neg_1() #0 { | ||
; CHECK-LABEL: neg_1: | ||
; CHECK: # %bb.0: | ||
; STATIC-NEXT: movl $foo-1, %eax | ||
; PIC-NEXT: leaq foo-1(%rip), %rax | ||
; MSTATIC-NEXT: movabsq $foo, %rax | ||
; MSTATIC-NEXT: decq %rax | ||
; MPIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax | ||
; MPIC-NEXT: movabsq $foo@GOTOFF, %rcx | ||
; MPIC-NEXT: leaq -1(%rax,%rcx), %rax | ||
entry: | ||
%0 = load i32, i32* @prev_length, align 4 ; <i32> [#uses=3] | ||
%1 = zext i32 %cur_match to i64 ; <i64> [#uses=1] | ||
%2 = sext i32 %0 to i64 ; <i64> [#uses=1] | ||
%.sum3 = add i64 %1, %2 ; <i64> [#uses=1] | ||
%3 = getelementptr [65536 x i8], [65536 x i8]* @window, i64 0, i64 %.sum3 ; <i8*> [#uses=1] | ||
%4 = load i8, i8* %3, align 1 ; <i8> [#uses=1] | ||
%5 = icmp eq i8 %4, 0 ; <i1> [#uses=1] | ||
br i1 %5, label %bb5, label %bb23 | ||
|
||
bb5: ; preds = %entry | ||
ret i32 %0 | ||
|
||
bb23: ; preds = %entry | ||
ret i32 %0 | ||
ret i64 add (i64 ptrtoint (i32* @foo to i64), i64 -1) | ||
} | ||
|
||
define dso_local i64 @neg_0x80000000() #0 { | ||
; CHECK-LABEL: neg_0x80000000: | ||
; CHECK: # %bb.0: | ||
; STATIC-NEXT: movl $foo-2147483648, %eax | ||
; PIC-NEXT: leaq foo-2147483648(%rip), %rax | ||
; MSTATIC-NEXT: movabsq $foo, %rax | ||
; MSTATIC-NEXT: addq $-2147483648, %rax | ||
; MPIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax | ||
; MPIC-NEXT: movabsq $foo@GOTOFF, %rcx | ||
; MPIC-NEXT: leaq -2147483648(%rax,%rcx), %rax | ||
entry: | ||
ret i64 add (i64 ptrtoint (i32* @foo to i64), i64 -2147483648) | ||
} | ||
|
||
define dso_local i64 @neg_0x80000001() #0 { | ||
; CHECK-LABEL: neg_0x80000001: | ||
; CHECK: # %bb.0: | ||
; STATIC-NEXT: movabsq $-2147483649, %rax | ||
; STATIC-NEXT: leaq foo(%rax), %rax | ||
; PIC-NEXT: leaq foo(%rip), %rcx | ||
; PIC-NEXT: movabsq $-2147483649, %rax | ||
; PIC-NEXT: addq %rcx, %rax | ||
; MSTATIC-NEXT: movabsq $-2147483649, %rcx | ||
; MSTATIC-NEXT: movabsq $foo, %rax | ||
; MSTATIC-NEXT: addq %rcx, %rax | ||
; MPIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax | ||
; MPIC-NEXT: movabsq $foo@GOTOFF, %rcx | ||
; MPIC-NEXT: addq %rax, %rcx | ||
; MPIC-NEXT: movabsq $-2147483649, %rax | ||
; MPIC-NEXT: addq %rcx, %rax | ||
entry: | ||
ret i64 add (i64 ptrtoint (i32* @foo to i64), i64 -2147483649) | ||
} | ||
|
||
attributes #0 = { nounwind } |