Home | History | Annotate | Download | only in X86
      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
      4 
      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
      8 
      9 ; Function Attrs: nounwind readnone uwtable
     10 define void @foo(i32 %x, i32 %d) #0 {
     11 entry:
     12   %a = alloca [8 x i32], align 16
     13   br label %while.cond
     14 
     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], [8 x i32]* %a, i32 0, i32 %d.addr.0
     18 
     19 ; CHECK: leaq	-40(%rsp,%r{{[^,]*}},4), %rax
     20 ; X32:   leal	-40(%rsp,%r{{[^,]*}},4), %eax
     21   %0 = load i32, i32* %arrayidx, align 4
     22   %cmp1 = icmp eq i32 %0, 0
     23   %inc = add nsw i32 %d.addr.0, 1
     24 
     25 ; CHECK: leaq	4(%r{{[^,]*}}), %r{{[^,]*}}
     26 ; X32:   leal	4(%r{{[^,]*}}), %e{{[^,]*}}
     27   br i1 %cmp1, label %while.end, label %while.cond
     28 
     29 while.end:                                        ; preds = %while.cond
     30   ret void
     31 }
     32 
     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.
     35 
     36 ; Function Attrs: nounwind readnone uwtable
     37 define void @bar(i32 %x, i32 %d) #0 {
     38 entry:
     39   %a = alloca [8 x i32], align 64
     40   br label %while.cond
     41 
     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], [8 x i32]* %a, i32 0, i32 %d.addr.0
     45 
     46 ; CHECK: leaq	(%rsp,%r{{[^,]*}},4), %rax
     47 ; X32:   leal	(%rsp,%r{{[^,]*}},4), %eax
     48   %0 = load i32, i32* %arrayidx, align 4
     49   %cmp1 = icmp eq i32 %0, 0
     50   %inc = add nsw i32 %d.addr.0, 1
     51 
     52 ; CHECK: leaq	4(%r{{[^,]*}}), %r{{[^,]*}}
     53 ; X32:   leal	4(%r{{[^,]*}}), %e{{[^,]*}}
     54   br i1 %cmp1, label %while.end, label %while.cond
     55 
     56 while.end:                                        ; preds = %while.cond
     57   ret void
     58 }
     59 
     60