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