OLD | NEW |
1 ; This is a basic test of the alloca instruction. | 1 ; This is a basic test of the alloca instruction. |
2 | 2 |
3 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ | 3 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ |
4 ; RUN: --target x8632 -i %s --args -O2 -allow-externally-defined-symbols \ | 4 ; RUN: --target x8632 -i %s --args -O2 -allow-externally-defined-symbols \ |
5 ; RUN: | %if --need=target_X8632 --command FileCheck %s | 5 ; RUN: | %if --need=target_X8632 --command FileCheck %s |
6 | 6 |
7 ; Test that a sequence of allocas with less than stack alignment get fused. | 7 ; Test that a sequence of allocas with less than stack alignment get fused. |
8 define internal void @fused_small_align(i32 %arg) { | 8 define internal void @fused_small_align(i32 %arg) { |
9 entry: | 9 entry: |
10 %a1 = alloca i8, i32 8, align 4 | 10 %a1 = alloca i8, i32 8, align 4 |
11 %a2 = alloca i8, i32 12, align 4 | 11 %a2 = alloca i8, i32 12, align 4 |
12 %a3 = alloca i8, i32 16, align 8 | 12 %a3 = alloca i8, i32 16, align 8 |
13 %p1 = bitcast i8* %a1 to i32* | 13 %p1 = bitcast i8* %a1 to i32* |
14 %p2 = bitcast i8* %a2 to i32* | 14 %p2 = bitcast i8* %a2 to i32* |
15 %p3 = bitcast i8* %a3 to i32* | 15 %p3 = bitcast i8* %a3 to i32* |
16 store i32 %arg, i32* %p1, align 1 | 16 store i32 %arg, i32* %p1, align 1 |
17 store i32 %arg, i32* %p2, align 1 | 17 store i32 %arg, i32* %p2, align 1 |
18 store i32 %arg, i32* %p3, align 1 | 18 store i32 %arg, i32* %p3, align 1 |
19 ret void | 19 ret void |
20 } | 20 } |
21 ; CHECK-LABEL: fused_small_align | 21 ; CHECK-LABEL: fused_small_align |
22 ; CHECK-NEXT: sub esp,0x30 | 22 ; CHECK-NEXT: sub esp,0x30 |
23 ; CHECK-NEXT: mov eax,DWORD PTR [esp+0x34] | 23 ; CHECK-NEXT: mov eax,DWORD PTR [esp+0x34] |
24 ; CHECK-NEXT: mov DWORD PTR [esp+0x1c],eax | |
25 ; CHECK-NEXT: mov DWORD PTR [esp+0x10],eax | 24 ; CHECK-NEXT: mov DWORD PTR [esp+0x10],eax |
| 25 ; CHECK-NEXT: mov DWORD PTR [esp+0x18],eax |
26 ; CHECK-NEXT: mov DWORD PTR [esp],eax | 26 ; CHECK-NEXT: mov DWORD PTR [esp],eax |
27 ; CHECK-NEXT: add esp,0x30 | 27 ; CHECK-NEXT: add esp,0x30 |
28 | 28 |
29 ; Test that a sequence of allocas with greater than stack alignment get fused. | 29 ; Test that a sequence of allocas with greater than stack alignment get fused. |
30 define internal void @fused_large_align(i32 %arg) { | 30 define internal void @fused_large_align(i32 %arg) { |
31 entry: | 31 entry: |
32 %a1 = alloca i8, i32 8, align 32 | 32 %a1 = alloca i8, i32 8, align 32 |
33 %a2 = alloca i8, i32 12, align 64 | 33 %a2 = alloca i8, i32 12, align 64 |
34 %a3 = alloca i8, i32 16, align 32 | 34 %a3 = alloca i8, i32 16, align 32 |
35 %p1 = bitcast i8* %a1 to i32* | 35 %p1 = bitcast i8* %a1 to i32* |
36 %p2 = bitcast i8* %a2 to i32* | 36 %p2 = bitcast i8* %a2 to i32* |
37 %p3 = bitcast i8* %a3 to i32* | 37 %p3 = bitcast i8* %a3 to i32* |
38 store i32 %arg, i32* %p1, align 1 | 38 store i32 %arg, i32* %p1, align 1 |
39 store i32 %arg, i32* %p2, align 1 | 39 store i32 %arg, i32* %p2, align 1 |
40 store i32 %arg, i32* %p3, align 1 | 40 store i32 %arg, i32* %p3, align 1 |
41 ret void | 41 ret void |
42 } | 42 } |
43 ; CHECK-LABEL: fused_large_align | 43 ; CHECK-LABEL: fused_large_align |
44 ; CHECK-NEXT: push ebp | 44 ; CHECK-NEXT: push ebp |
45 ; CHECK-NEXT: mov ebp,esp | 45 ; CHECK-NEXT: mov ebp,esp |
46 ; CHECK-NEXT: sub esp,0x80 | 46 ; CHECK-NEXT: sub esp,0x80 |
47 ; CHECK-NEXT: and esp,0xffffffc0 | 47 ; CHECK-NEXT: and esp,0xffffffc0 |
48 ; CHECK-NEXT: mov eax,DWORD PTR [ebp+0x8] | 48 ; CHECK-NEXT: mov eax,DWORD PTR [ebp+0x8] |
| 49 ; CHECK-NEXT: mov DWORD PTR [esp+0x40],eax |
| 50 ; CHECK-NEXT: mov DWORD PTR [esp],eax |
49 ; CHECK-NEXT: mov DWORD PTR [esp+0x60],eax | 51 ; CHECK-NEXT: mov DWORD PTR [esp+0x60],eax |
50 ; CHECK-NEXT: mov DWORD PTR [esp],eax | |
51 ; CHECK-NEXT: mov DWORD PTR [esp+0x40],eax | |
52 ; CHECK-NEXT: mov esp,ebp | 52 ; CHECK-NEXT: mov esp,ebp |
53 ; CHECK-NEXT: pop ebp | 53 ; CHECK-NEXT: pop ebp |
54 | 54 |
55 ; Test that an interior pointer into a rematerializable variable is also | 55 ; Test that an interior pointer into a rematerializable variable is also |
56 ; rematerializable, and test that it is detected even when the use appears | 56 ; rematerializable, and test that it is detected even when the use appears |
57 ; syntactically before the definition. Test that it is folded into mem | 57 ; syntactically before the definition. Test that it is folded into mem |
58 ; operands, and also rematerializable through an lea instruction for direct use. | 58 ; operands, and also rematerializable through an lea instruction for direct use. |
59 define internal i32 @fused_derived(i32 %arg) { | 59 define internal i32 @fused_derived(i32 %arg) { |
60 entry: | 60 entry: |
61 %a1 = alloca i8, i32 128, align 4 | 61 %a1 = alloca i8, i32 128, align 4 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 ; CHECK-NEXT: sub esp,0x24 | 147 ; CHECK-NEXT: sub esp,0x24 |
148 ; CHECK-NEXT: mov eax,DWORD PTR [ebp+0xc] | 148 ; CHECK-NEXT: mov eax,DWORD PTR [ebp+0xc] |
149 ; CHECK-NEXT: and esp,0xffffffe0 | 149 ; CHECK-NEXT: and esp,0xffffffe0 |
150 ; CHECK-NEXT: sub esp,0x40 | 150 ; CHECK-NEXT: sub esp,0x40 |
151 ; CHECK-NEXT: mov ecx,esp | 151 ; CHECK-NEXT: mov ecx,esp |
152 ; CHECK-NEXT: mov edx,ecx | 152 ; CHECK-NEXT: mov edx,ecx |
153 ; CHECK-NEXT: add ecx,0x20 | 153 ; CHECK-NEXT: add ecx,0x20 |
154 ; CHECK-NEXT: add edx,0x0 | 154 ; CHECK-NEXT: add edx,0x0 |
155 ; CHECK-NEXT: sub esp,0x10 | 155 ; CHECK-NEXT: sub esp,0x10 |
156 ; CHECK-NEXT: mov ebx,esp | 156 ; CHECK-NEXT: mov ebx,esp |
| 157 ; CHECK-NEXT: mov DWORD PTR [edx],eax |
157 ; CHECK-NEXT: mov DWORD PTR [ecx],eax | 158 ; CHECK-NEXT: mov DWORD PTR [ecx],eax |
158 ; CHECK-NEXT: mov DWORD PTR [edx],eax | 159 ; CHECK-NEXT: mov DWORD PTR [ebp-0x14],eax |
159 ; CHECK-NEXT: mov DWORD PTR [ebp-0x24],eax | 160 ; CHECK-NEXT: mov DWORD PTR [ebp-0x24],eax |
160 ; CHECK-NEXT: mov DWORD PTR [ebp-0x14],eax | |
161 ; CHECK-NEXT: mov DWORD PTR [ebx],eax | 161 ; CHECK-NEXT: mov DWORD PTR [ebx],eax |
162 ; CHECK-NEXT: mov esp,ebp | 162 ; CHECK-NEXT: mov esp,ebp |
163 ; CHECK-NEXT: pop ebp | 163 ; CHECK-NEXT: pop ebp |
OLD | NEW |