File: pr18705.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 (58 lines) | stat: -rw-r--r-- 2,283 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
; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s

; Since neither of while.body's out-edges is an exit or a back edge,
; calcLoopBranchHeuristics should return early without setting the weights.
; calcFloatingPointHeuristics, which is run later, sets the weights.
;
; CHECK: edge while.body -> if.then probability is 0x50000000 / 0x80000000 = 62.50%
; CHECK: edge while.body -> if.else probability is 0x30000000 / 0x80000000 = 37.50%

define void @foo1(i32 %n, ptr nocapture %b, ptr nocapture %c, ptr nocapture %d, ptr nocapture readonly %f0, ptr nocapture readonly %f1) {
entry:
  %tobool8 = icmp eq i32 %n, 0
  br i1 %tobool8, label %while.end, label %while.body.lr.ph

while.body.lr.ph:
  %0 = sext i32 %n to i64
  br label %while.body

while.body:
  %indvars.iv = phi i64 [ %0, %while.body.lr.ph ], [ %indvars.iv.next, %if.end ]
  %b.addr.011 = phi ptr [ %b, %while.body.lr.ph ], [ %b.addr.1, %if.end ]
  %d.addr.010 = phi ptr [ %d, %while.body.lr.ph ], [ %incdec.ptr4, %if.end ]
  %c.addr.09 = phi ptr [ %c, %while.body.lr.ph ], [ %c.addr.1, %if.end ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %arrayidx = getelementptr inbounds float, ptr %f0, i64 %indvars.iv.next
  %1 = load float, ptr %arrayidx, align 4
  %arrayidx2 = getelementptr inbounds float, ptr %f1, i64 %indvars.iv.next
  %2 = load float, ptr %arrayidx2, align 4
  %cmp = fcmp une float %1, %2
  br i1 %cmp, label %if.then, label %if.else

if.then:
  %incdec.ptr = getelementptr inbounds i32, ptr %b.addr.011, i64 1
  %3 = load i32, ptr %b.addr.011, align 4
  %add = add nsw i32 %3, 12
  store i32 %add, ptr %b.addr.011, align 4
  br label %if.end

if.else:
  %incdec.ptr3 = getelementptr inbounds i32, ptr %c.addr.09, i64 1
  %4 = load i32, ptr %c.addr.09, align 4
  %sub = add nsw i32 %4, -13
  store i32 %sub, ptr %c.addr.09, align 4
  br label %if.end

if.end:
  %c.addr.1 = phi ptr [ %c.addr.09, %if.then ], [ %incdec.ptr3, %if.else ]
  %b.addr.1 = phi ptr [ %incdec.ptr, %if.then ], [ %b.addr.011, %if.else ]
  %incdec.ptr4 = getelementptr inbounds i32, ptr %d.addr.010, i64 1
  store i32 14, ptr %d.addr.010, align 4
  %5 = trunc i64 %indvars.iv.next to i32
  %tobool = icmp eq i32 %5, 0
  br i1 %tobool, label %while.end, label %while.body

while.end:
  ret void
}