llvm.org GIT mirror llvm / ae37c2a
Add several testcases for new optimizations in the code generator. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19244 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 15 years ago
3 changed file(s) with 62 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; The register allocator can commute two-address instructions to avoid
1 ; insertion of register-register copies.
2
3 ; Check that there are no register-register copies left.
4 ; RUN: llvm-as < %s | llc -march=x86 -x86-asm-syntax=intel | not grep 'mov %E.X, %E.X'
5
6 %G = external global int
7
8 declare void %ext(int)
9
10 int %add_test(int %X, int %Y) {
11 %Z = add int %X, %Y ;; Last use of Y, but not of X.
12 store int %Z, int* %G
13 ret int %X
14 }
15
16 int %xor_test(int %X, int %Y) {
17 %Z = xor int %X, %Y ;; Last use of Y, but not of X.
18 store int %Z, int* %G
19 ret int %X
20 }
0 ;; X's live range extends beyond the shift, so the register allocator
1 ;; cannot coallesce it with Y. Because of this, a copy needs to be
2 ;; emitted before the shift to save the register value before it is
3 ;; clobbered. However, this copy is not needed if the register
4 ;; allocator turns the shift into an LEA. This also occurs for ADD.
5
6 ; Check that the shift gets turned into an LEA.
7
8 ; RUN: llvm-as < %s | llc -march=x86 -x86-asm-syntax=intel | not grep 'mov %E.X, %E.X'
9
10 %G = external global int
11
12 int %test1(int %X, int %Y) {
13 %Z = add int %X, %Y
14 volatile store int %Y, int* %G
15 volatile store int %Z, int* %G
16 ret int %X
17 }
18
19 int %test2(int %X) {
20 %Z = add int %X, 1 ;; inc
21 volatile store int %Z, int* %G
22 ret int %X
23 }
0 ;; X's live range extends beyond the shift, so the register allocator
1 ;; cannot coallesce it with Y. Because of this, a copy needs to be
2 ;; emitted before the shift to save the register value before it is
3 ;; clobbered. However, this copy is not needed if the register
4 ;; allocator turns the shift into an LEA. This also occurs for ADD.
5
6 ; Check that the shift gets turned into an LEA.
7
8 ; RUN: llvm-as < %s | llc -march=x86 -x86-asm-syntax=intel | not grep 'mov %E.X, %E.X'
9
10 %G = external global int
11
12 int %test1(int %X) {
13 %Z = shl int %X, ubyte 2
14 volatile store int %Z, int* %G
15 ret int %X
16 }