OLD | NEW |
1 ; This tests a simple loop that sums the elements of an input array. | 1 ; This tests a simple loop that sums the elements of an input array. |
2 ; The O2 check patterns represent the best code currently achieved. | 2 ; The O2 check patterns represent the best code currently achieved. |
3 | 3 |
4 ; RUN: %llvm2ice -O2 --verbose none %s | FileCheck %s | |
5 ; RUN: %llvm2ice -Om1 --verbose none %s | FileCheck --check-prefix=OPTM1 %s | |
6 ; RUN: %llvm2ice -O2 --verbose none %s \ | 4 ; RUN: %llvm2ice -O2 --verbose none %s \ |
7 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj | 5 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| 6 ; RUN: | llvm-objdump -d -symbolize -x86-asm-syntax=intel - | FileCheck %s |
8 ; RUN: %llvm2ice -Om1 --verbose none %s \ | 7 ; RUN: %llvm2ice -Om1 --verbose none %s \ |
9 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj | 8 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| 9 ; RUN: | llvm-objdump -d -symbolize -x86-asm-syntax=intel - \ |
| 10 ; RUN: | FileCheck --check-prefix=OPTM1 %s |
10 ; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s | 11 ; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s |
11 ; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s | 12 ; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s |
12 ; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \ | 13 ; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \ |
13 ; RUN: | FileCheck --check-prefix=DUMP %s | 14 ; RUN: | FileCheck --check-prefix=DUMP %s |
14 | 15 |
15 define i32 @simple_loop(i32 %a, i32 %n) { | 16 define i32 @simple_loop(i32 %a, i32 %n) { |
16 entry: | 17 entry: |
17 %cmp4 = icmp sgt i32 %n, 0 | 18 %cmp4 = icmp sgt i32 %n, 0 |
18 br i1 %cmp4, label %for.body, label %for.end | 19 br i1 %cmp4, label %for.body, label %for.end |
19 | 20 |
20 for.body: | 21 for.body: |
21 %i.06 = phi i32 [ %inc, %for.body ], [ 0, %entry ] | 22 %i.06 = phi i32 [ %inc, %for.body ], [ 0, %entry ] |
22 %sum.05 = phi i32 [ %add, %for.body ], [ 0, %entry ] | 23 %sum.05 = phi i32 [ %add, %for.body ], [ 0, %entry ] |
23 %gep_array = mul i32 %i.06, 4 | 24 %gep_array = mul i32 %i.06, 4 |
24 %gep = add i32 %a, %gep_array | 25 %gep = add i32 %a, %gep_array |
25 %__9 = inttoptr i32 %gep to i32* | 26 %__9 = inttoptr i32 %gep to i32* |
26 %v0 = load i32* %__9, align 1 | 27 %v0 = load i32* %__9, align 1 |
27 %add = add i32 %v0, %sum.05 | 28 %add = add i32 %v0, %sum.05 |
28 %inc = add i32 %i.06, 1 | 29 %inc = add i32 %i.06, 1 |
29 %cmp = icmp slt i32 %inc, %n | 30 %cmp = icmp slt i32 %inc, %n |
30 br i1 %cmp, label %for.body, label %for.end | 31 br i1 %cmp, label %for.body, label %for.end |
31 | 32 |
32 for.end: | 33 for.end: |
33 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ] | 34 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ] |
34 ret i32 %sum.0.lcssa | 35 ret i32 %sum.0.lcssa |
35 } | 36 } |
36 | 37 |
37 ; CHECK: .globl simple_loop | 38 ; CHECK-LABEL: simple_loop |
38 ; CHECK: mov ecx, dword ptr [esp+{{[0-9]+}}] | 39 ; CHECK: mov ecx, dword ptr [esp{{.*}}+{{.*}}{{[0-9]+}}] |
39 ; CHECK: cmp ecx, 0 | 40 ; CHECK: cmp ecx, 0 |
40 ; CHECK-NEXT: jg {{.*}}for.body | 41 ; CHECK-NEXT: jg {{[0-9]}} |
41 ; CHECK-NEXT: jmp {{.*}}for.end | 42 ; NaCl bundle padding |
| 43 ; CHECK-NEXT: nop |
| 44 ; CHECK-NEXT: jmp {{[0-9]}} |
42 | 45 |
43 ; TODO: the mov from ebx to esi seems redundant here - so this may need to be | 46 ; TODO: the mov from ebx to esi seems redundant here - so this may need to be |
44 ; modified later | 47 ; modified later |
45 | 48 |
46 ; CHECK: add [[IREG:[a-z]+]], 1 | 49 ; CHECK: add [[IREG:[a-z]+]], 1 |
47 ; CHECK-NEXT: mov [[ICMPREG:[a-z]+]], [[IREG]] | 50 ; CHECK-NEXT: mov [[ICMPREG:[a-z]+]], [[IREG]] |
48 ; CHECK: cmp [[ICMPREG]], ecx | 51 ; CHECK: cmp [[ICMPREG]], ecx |
49 ; CHECK-NEXT: jl {{.*}}for.body | 52 ; CHECK-NEXT: jl -{{[0-9]}} |
50 ; | 53 ; |
51 ; There's nothing remarkable under Om1 to test for, since Om1 generates | 54 ; There's nothing remarkable under Om1 to test for, since Om1 generates |
52 ; such atrocious code (by design). | 55 ; such atrocious code (by design). |
53 ; OPTM1: .globl simple_loop | 56 ; OPTM1-LABEL: simple_loop |
54 ; OPTM1: cmp {{.*}}, 0 | 57 ; OPTM1: cmp {{.*}}, 0 |
55 ; OPTM1: jg | 58 ; OPTM1: jg |
56 ; OPTM1: ret | 59 ; OPTM1: ret |
57 | 60 |
58 ; ERRORS-NOT: ICE translation error | 61 ; ERRORS-NOT: ICE translation error |
59 ; DUMP-NOT: SZ | 62 ; DUMP-NOT: SZ |
OLD | NEW |