File: function-specialization-loop.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 (63 lines) | stat: -rw-r--r-- 1,503 bytes parent folder | download | duplicates (4)
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
60
61
62
63
; RUN: opt -function-specialization -func-specialization-avg-iters-cost=3 -func-specialization-size-threshold=10 -S < %s | FileCheck %s

; Check that the loop depth results in a larger specialization bonus.
; CHECK: @foo.1(
; CHECK: @foo.2(

target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"

@A = external dso_local constant i32, align 4
@B = external dso_local constant i32, align 4
@C = external dso_local constant i32, align 4
@D = external dso_local constant i32, align 4

declare i1 @cond_begin()
declare i1 @cond_end()
declare i1 @getCond()

define internal i32 @foo(i32 %x, i32* %b, i32* %c) {
entry:
  br label %loop.entry

loop.entry:
  br label %loop2.entry

loop2.entry:
  br label %loop2.body

loop2.body:
  %0 = load i32, i32* %b, align 4
  %1 = load i32, i32* %c, align 4
  %add.0 = add nsw i32 %0, %1
  %add = add nsw i32 %add.0, %x
  br label %loop2.end

loop2.end:
  %cond.end = call i1 @cond_end()
  br i1 %cond.end, label %loop2.entry, label %loop.end

loop.end:
  %cond2.end = call i1 @getCond()
  br i1 %cond2.end, label %loop.entry, label %return

return:
  ret i32 %add
}

define dso_local i32 @bar(i32 %x, i32 %y) {
entry:
  %tobool = icmp ne i32 %x, 0
  br i1 %tobool, label %if.then, label %if.else

if.then:
  %call = call i32 @foo(i32 %x, i32* @A, i32* @C)
  br label %return

if.else:
  %call1 = call i32 @foo(i32 %y, i32* @B, i32* @D)
  br label %return

return:
  %retval.0 = phi i32 [ %call, %if.then ], [ %call1, %if.else ]
  ret i32 %retval.0
}