File: guarded_unsafeblock_peel.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (72 lines) | stat: -rw-r--r-- 2,914 bytes parent folder | download | duplicates (11)
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
64
65
66
67
68
69
70
71
72
; RUN: opt -S -passes=loop-fusion -loop-fusion-peel-max-count=3 < %s | FileCheck %s

; Tests that we do not fuse two guarded loops together.
; These loops do not have the same trip count, and the first loop meets the
; requirements for peeling. However, the exit block of the first loop makes the
; loops unsafe to fuse together.
; The expected output of this test is the function as below.

; CHECK-LABEL: void @unsafe_exitblock(ptr noalias %A, ptr noalias %B)
; CHECK:       for.first.guard
; CHECK:         br i1 %cmp3, label %for.first.preheader, label %for.second.guard
; CHECK:       for.first.preheader:
; CHECK-NEXT:    br label %for.first
; CHECK:       for.first:
; CHECK:         br i1 %cmp, label %for.first, label %for.first.exit
; CHECK:       for.first.exit:
; CHECK-NEXT:    call void @bar()
; CHECK-NEXT:    br label %for.second.guard
; CHECK:       for.second.guard:
; CHECK:         br i1 %cmp21, label %for.second.preheader, label %for.end
; CHECK:       for.second.preheader:
; CHECK-NEXT:    br label %for.second
; CHECK:       for.second:
; CHECK:         br i1 %cmp2, label %for.second, label %for.second.exit
; CHECK:       for.second.exit:
; CHECK-NEXT:    br label %for.end
; CHECK:       for.end:
; CHECK-NEXT:    ret void

define void @unsafe_exitblock(ptr noalias %A, ptr noalias %B) {
for.first.guard:
  %cmp3 = icmp slt i64 0, 45
  br i1 %cmp3, label %for.first.preheader, label %for.second.guard

for.first.preheader:                             ; preds = %for.first.guard
  br label %for.first

for.first:                                       ; preds = %for.first.preheader, %for.first
  %i.04 = phi i64 [ %inc, %for.first ], [ 0, %for.first.preheader ]
  %arrayidx = getelementptr inbounds i32, ptr %A, i64 %i.04
  store i32 0, ptr %arrayidx, align 4
  %inc = add nsw i64 %i.04, 1
  %cmp = icmp slt i64 %inc, 45
  br i1 %cmp, label %for.first, label %for.first.exit

for.first.exit:                                  ; preds = %for.first
  call void @bar()
  br label %for.second.guard

for.second.guard:                                ; preds = %for.first.exit, %for.first.guard
  %cmp21 = icmp slt i64 2,45
  br i1 %cmp21, label %for.second.preheader, label %for.end

for.second.preheader:                            ; preds = %for.second.guard
  br label %for.second

for.second:                                      ; preds = %for.second.preheader, %for.second
  %j.02 = phi i64 [ %inc6, %for.second ], [ 2, %for.second.preheader ]
  %arrayidx4 = getelementptr inbounds i32, ptr %B, i64 %j.02
  store i32 0, ptr %arrayidx4, align 4
  %inc6 = add nsw i64 %j.02, 1
  %cmp2 = icmp slt i64 %inc6, 45
  br i1 %cmp2, label %for.second, label %for.second.exit

for.second.exit:                                 ; preds = %for.second
  br label %for.end

for.end:                                         ; preds = %for.second.exit, %for.second.guard
  ret void
}

declare void @bar()