File: atom-fixup-lea3.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (56 lines) | stat: -rw-r--r-- 1,974 bytes parent folder | download | duplicates (13)
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
; RUN: llc < %s -mcpu=atom -mtriple=i686-linux | FileCheck %s
; CHECK: addl ({{%[a-z]+}},[[reg:%[a-z]+]],4)
; CHECK-NEXT: movl
; CHECK-NEXT: addl 4({{%[a-z]+}},[[reg:%[a-z]+]],4)
; CHECK-NEXT: incl

; Test for the FixupLEAs pre-emit pass.
; An LEA should NOT be substituted for the ADD instruction
; that increments the array pointer if it is greater than 5 instructions
; away from the memory reference that uses it.

; Original C code: clang -m32 -S -O2
;int test(int n, int * array, int * m, int * array2)
;{
;  int i, j = 0;
;  int sum = 0;
;  for (i = 0, j = 0; i < n;) {
;    ++i;
;    *m += array2[j++];
;    sum += array[i];
;  }
;  return sum;
;}

define i32 @test(i32 %n, ptr nocapture %array, ptr nocapture %k, ptr nocapture %l, ptr nocapture %m, ptr nocapture %array2) #0 {
entry:
  %cmp7 = icmp sgt i32 %n, 0
  br i1 %cmp7, label %for.body.lr.ph, label %for.end

for.body.lr.ph:                                   ; preds = %entry
  %.pre = load i32, ptr %m, align 4
  br label %for.body

for.body:                                         ; preds = %for.body, %for.body.lr.ph
  %0 = phi i32 [ %.pre, %for.body.lr.ph ], [ %add, %for.body ]
  %sum.010 = phi i32 [ 0, %for.body.lr.ph ], [ %add3, %for.body ]
  %j.09 = phi i32 [ 0, %for.body.lr.ph ], [ %inc1, %for.body ]
  %inc1 = add nsw i32 %j.09, 1
  %arrayidx = getelementptr inbounds i32, ptr %array2, i32 %j.09
  store i32 %0, ptr %m, align 4
  store i32 %sum.010, ptr %m, align 4
  store i32 %0, ptr %m, align 4
  %1 = load i32, ptr %arrayidx, align 4
  %add = add nsw i32 %0, %1
  store i32 %add, ptr %m, align 4
  %arrayidx2 = getelementptr inbounds i32, ptr %array, i32 %inc1
  %2 = load i32, ptr %arrayidx2, align 4
  %add3 = add nsw i32 %2, %sum.010
  %exitcond = icmp eq i32 %inc1, %n
  br i1 %exitcond, label %for.end, label %for.body

for.end:                                          ; preds = %for.body, %entry
  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add3, %for.body ]
  ret i32 %sum.0.lcssa
}