File: ephemeral.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 (44 lines) | stat: -rw-r--r-- 1,389 bytes parent folder | download | duplicates (22)
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
; RUN: opt < %s -S -loop-unroll -unroll-threshold=50 | FileCheck %s

; Make sure this loop is completely unrolled...
; CHECK-LABEL: @test1
; CHECK: for.body:
; CHECK-NOT: for.end:

define i32 @test1(i32* nocapture %a) nounwind uwtable readonly {
entry:
  br label %for.body

for.body:                                         ; preds = %for.body, %entry
  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
  %sum.01 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
  %0 = load i32, i32* %arrayidx, align 4

  ; This loop will be completely unrolled, even with these extra instructions,
  ; but only because they're ephemeral (and, thus, free).
  %1 = add nsw i32 %0, 2
  %2 = add nsw i32 %1, 4
  %3 = add nsw i32 %2, 4
  %4 = add nsw i32 %3, 4
  %5 = add nsw i32 %4, 4
  %6 = add nsw i32 %5, 4
  %7 = add nsw i32 %6, 4
  %8 = add nsw i32 %7, 4
  %9 = add nsw i32 %8, 4
  %10 = add nsw i32 %9, 4
  %ca = icmp sgt i32 %10, -7
  call void @llvm.assume(i1 %ca)

  %add = add nsw i32 %0, %sum.01
  %indvars.iv.next = add i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond = icmp eq i32 %lftr.wideiv, 5
  br i1 %exitcond, label %for.end, label %for.body

for.end:                                          ; preds = %for.body
  ret i32 %add
}

declare void @llvm.assume(i1) nounwind