llvm/test/CodeGen/X86/lea-5.ll
Pavel Chupin aadaac228d [x32] Fix FrameIndex check in SelectLEA64_32Addr
Summary:
Fixes http://llvm.org/bugs/show_bug.cgi?id=20016 reproducible on new
lea-5.ll case.
Also use RSP/RBP for x32 lea to save 1 byte used for 0x67 prefix in
ESP/EBP case.

Test Plan: lea tests modified to include x32/nacl and new test added

Reviewers: nadav, dschuff, t.p.northover

Subscribers: llvm-commits, zinovy.nis

Differential Revision: http://reviews.llvm.org/D4929

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216065 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-20 11:59:22 +00:00

60 lines
2.0 KiB
LLVM

; test for more complicated forms of lea operands which can be generated
; in loop optimized cases.
; See also http://llvm.org/bugs/show_bug.cgi?id=20016
; RUN: llc < %s -mtriple=x86_64-linux -O2 | FileCheck %s
; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -O2 | FileCheck %s -check-prefix=X32
; RUN: llc < %s -mtriple=x86_64-nacl -O2 | FileCheck %s -check-prefix=X32
; Function Attrs: nounwind readnone uwtable
define void @foo(i32 %x, i32 %d) #0 {
entry:
%a = alloca [8 x i32], align 16
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%d.addr.0 = phi i32 [ %d, %entry ], [ %inc, %while.cond ]
%arrayidx = getelementptr inbounds [8 x i32]* %a, i32 0, i32 %d.addr.0
; CHECK: leaq -40(%rsp,%r{{[^,]*}},4), %rax
; X32: leal -40(%rsp,%r{{[^,]*}},4), %eax
%0 = load i32* %arrayidx, align 4
%cmp1 = icmp eq i32 %0, 0
%inc = add nsw i32 %d.addr.0, 1
; CHECK: leaq 4(%r{{[^,]*}}), %r{{[^,]*}}
; X32: leal 4(%r{{[^,]*}}), %e{{[^,]*}}
br i1 %cmp1, label %while.end, label %while.cond
while.end: ; preds = %while.cond
ret void
}
; The same test as above but with enforsed stack realignment (%a aligned by 64)
; to check one more case of correct lea generation.
; Function Attrs: nounwind readnone uwtable
define void @bar(i32 %x, i32 %d) #0 {
entry:
%a = alloca [8 x i32], align 64
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%d.addr.0 = phi i32 [ %d, %entry ], [ %inc, %while.cond ]
%arrayidx = getelementptr inbounds [8 x i32]* %a, i32 0, i32 %d.addr.0
; CHECK: leaq (%rsp,%r{{[^,]*}},4), %rax
; X32: leal (%rsp,%r{{[^,]*}},4), %eax
%0 = load i32* %arrayidx, align 4
%cmp1 = icmp eq i32 %0, 0
%inc = add nsw i32 %d.addr.0, 1
; CHECK: leaq 4(%r{{[^,]*}}), %r{{[^,]*}}
; X32: leal 4(%r{{[^,]*}}), %e{{[^,]*}}
br i1 %cmp1, label %while.end, label %while.cond
while.end: ; preds = %while.cond
ret void
}