File: lea-5.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (59 lines) | stat: -rw-r--r-- 2,075 bytes parent folder | download | duplicates (20)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
; 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], [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, 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], [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, 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
}