Robert Lougher | c69cfee | 2015-01-29 16:18:29 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -mtriple=x86_64-linux-unknown | FileCheck %s --check-prefix=CHECK-64 |
| 2 | ; RUN: llc < %s -mtriple=i386-linux-unknown | FileCheck %s --check-prefix=CHECK-32 |
| 3 | |
| 4 | ; Test that a large stack offset uses a single add/sub instruction to |
| 5 | ; adjust the stack pointer. |
| 6 | |
| 7 | define void @foo() nounwind { |
| 8 | ; CHECK-64-LABEL: foo: |
| 9 | ; CHECK-64: movabsq $50000000{{..}}, %rax |
| 10 | ; CHECK-64-NEXT: subq %rax, %rsp |
| 11 | ; CHECK-64-NOT: subq $2147483647, %rsp |
| 12 | ; CHECK-64: movabsq $50000000{{..}}, [[RAX:%r..]] |
| 13 | ; CHECK-64-NEXT: addq [[RAX]], %rsp |
| 14 | |
| 15 | ; CHECK-32-LABEL: foo: |
| 16 | ; CHECK-32: movl $50000000{{..}}, %eax |
| 17 | ; CHECK-32-NEXT: subl %eax, %esp |
| 18 | ; CHECK-32-NOT: subl $2147483647, %esp |
| 19 | ; CHECK-32: movl $50000000{{..}}, [[EAX:%e..]] |
| 20 | ; CHECK-32-NEXT: addl [[EAX]], %esp |
| 21 | %1 = alloca [5000000000 x i8], align 16 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 22 | %2 = getelementptr inbounds [5000000000 x i8], [5000000000 x i8]* %1, i32 0, i32 0 |
Robert Lougher | c69cfee | 2015-01-29 16:18:29 +0000 | [diff] [blame] | 23 | call void @bar(i8* %2) |
| 24 | ret void |
| 25 | } |
| 26 | |
| 27 | ; Verify that we do not clobber the return value. |
| 28 | |
| 29 | define i32 @foo2() nounwind { |
| 30 | ; CHECK-64-LABEL: foo2: |
| 31 | ; CHECK-64: movl $10, %eax |
| 32 | ; CHECK-64-NOT: movabsq ${{.*}}, %rax |
| 33 | |
| 34 | ; CHECK-32-LABEL: foo2: |
| 35 | ; CHECK-32: movl $10, %eax |
| 36 | ; CHECK-32-NOT: movl ${{.*}}, %eax |
| 37 | %1 = alloca [5000000000 x i8], align 16 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 38 | %2 = getelementptr inbounds [5000000000 x i8], [5000000000 x i8]* %1, i32 0, i32 0 |
Robert Lougher | c69cfee | 2015-01-29 16:18:29 +0000 | [diff] [blame] | 39 | call void @bar(i8* %2) |
| 40 | ret i32 10 |
| 41 | } |
| 42 | |
| 43 | ; Verify that we do not clobber EAX when using inreg attribute |
| 44 | |
| 45 | define i32 @foo3(i32 inreg %x) nounwind { |
| 46 | ; CHECK-64-LABEL: foo3: |
| 47 | ; CHECK-64: movabsq $50000000{{..}}, %rax |
| 48 | ; CHECK-64-NEXT: subq %rax, %rsp |
| 49 | |
| 50 | ; CHECK-32-LABEL: foo3: |
| 51 | ; CHECK-32: subl $2147483647, %esp |
| 52 | ; CHECK-32-NOT: movl ${{.*}}, %eax |
| 53 | %1 = alloca [5000000000 x i8], align 16 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 54 | %2 = getelementptr inbounds [5000000000 x i8], [5000000000 x i8]* %1, i32 0, i32 0 |
Robert Lougher | c69cfee | 2015-01-29 16:18:29 +0000 | [diff] [blame] | 55 | call void @bar(i8* %2) |
| 56 | ret i32 %x |
| 57 | } |
| 58 | |
| 59 | declare void @bar(i8*) |