1 ; test for more complicated forms of lea operands which can be generated
2 ; in loop optimized cases.
3 ; See also http://llvm.org/bugs/show_bug.cgi?id=20016
5 ; RUN: llc < %s -mtriple=x86_64-linux -O2 | FileCheck %s
6 ; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -O2 | FileCheck %s -check-prefix=X32
7 ; RUN: llc < %s -mtriple=x86_64-nacl -O2 | FileCheck %s -check-prefix=X32
9 ; Function Attrs: nounwind readnone uwtable
10 define void @foo(i32 %x, i32 %d) #0 {
12 %a = alloca [8 x i32], align 16
15 while.cond: ; preds = %while.cond, %entry
16 %d.addr.0 = phi i32 [ %d, %entry ], [ %inc, %while.cond ]
17 %arrayidx = getelementptr inbounds [8 x i32], ptr %a, i32 0, i32 %d.addr.0
19 ; CHECK: leaq -40(%rsp,%r{{[^,]*}},4), %rax
20 ; X32: leal -40(%rsp,%r{{[^,]*}},4), %eax
21 %0 = load i32, ptr %arrayidx, align 4
22 %cmp1 = icmp eq i32 %0, 0
23 %inc = add nsw i32 %d.addr.0, 1
25 ; CHECK: leaq 4(%r{{[^,]*}}), %r{{[^,]*}}
26 ; X32: leal 4(%r{{[^,]*}}), %e{{[^,]*}}
27 br i1 %cmp1, label %while.end, label %while.cond
29 while.end: ; preds = %while.cond
33 ; The same test as above but with enforsed stack realignment (%a aligned by 64)
34 ; to check one more case of correct lea generation.
36 ; Function Attrs: nounwind readnone uwtable
37 define void @bar(i32 %x, i32 %d) #0 {
39 %a = alloca [8 x i32], align 64
42 while.cond: ; preds = %while.cond, %entry
43 %d.addr.0 = phi i32 [ %d, %entry ], [ %inc, %while.cond ]
44 %arrayidx = getelementptr inbounds [8 x i32], ptr %a, i32 0, i32 %d.addr.0
46 ; CHECK: leaq (%rsp,%r{{[^,]*}},4), %rax
47 ; X32: leal (%rsp,%r{{[^,]*}},4), %eax
48 %0 = load i32, ptr %arrayidx, align 4
49 %cmp1 = icmp eq i32 %0, 0
50 %inc = add nsw i32 %d.addr.0, 1
52 ; CHECK: leaq 4(%r{{[^,]*}}), %r{{[^,]*}}
53 ; X32: leal 4(%r{{[^,]*}}), %e{{[^,]*}}
54 br i1 %cmp1, label %while.end, label %while.cond
56 while.end: ; preds = %while.cond