File: runtime-check-trip-count-decisions.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 (108 lines) | stat: -rw-r--r-- 4,377 bytes parent folder | download | duplicates (8)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
; RUN: opt < %s -passes=loop-vectorize -mtriple aarch64-unknown-linux-gnu -mattr=+sve -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue -S | FileCheck --check-prefixes=CHECK,PREDICATED %s
; RUN: opt < %s -passes=loop-vectorize -mtriple aarch64-unknown-linux-gnu -mattr=+sve -prefer-predicate-over-epilogue=scalar-epilogue -S | FileCheck --check-prefixes=CHECK,SCALAR %s

; This file contains the same function but with different trip-count PGO hints

; The function is vectorized if there are no trip-count hints
define i32 @foo_no_trip_count(ptr %a, ptr %b, ptr %c, i32 %bound) {
; CHECK-LABEL: @foo_no_trip_count(
; PREDICATED: vector.body
; SCALAR: vector.body
entry:
  br label %for.body

for.body:                                         ; preds = %for.body, %entry
  %idx = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %a.index = getelementptr inbounds [32 x i8], ptr %a, i32 0, i32 %idx
  %0 = load i8, ptr %a.index, align 1
  %b.index = getelementptr inbounds [32 x i8], ptr %b, i32 0, i32 %idx
  %1 = load i8, ptr %b.index, align 1
  %2 = add i8 %0, %1
  %c.index = getelementptr inbounds [32 x i8], ptr %c, i32 0, i32 %idx
  store i8 %2, ptr %c.index, align 1
  %inc = add nsw i32 %idx, 1
  %exitcond = icmp eq i32 %idx, %bound
  br i1 %exitcond, label %for.end, label %for.body

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

; If trip-count is equal to 4, the function is not vectorised
define i32 @foo_low_trip_count(ptr %a, ptr %b, ptr %c, i32 %bound) {
; CHECK-LABEL: @foo_low_trip_count(
; PREDICATED-NOT: vector.body
; SCALAR-NOT: vector.body
entry:
  br label %for.body

for.body:                                         ; preds = %for.body, %entry
  %idx = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %a.index = getelementptr inbounds [32 x i8], ptr %a, i32 0, i32 %idx
  %0 = load i8, ptr %a.index, align 1
  %b.index = getelementptr inbounds [32 x i8], ptr %b, i32 0, i32 %idx
  %1 = load i8, ptr %b.index, align 1
  %2 = add i8 %0, %1
  %c.index = getelementptr inbounds [32 x i8], ptr %c, i32 0, i32 %idx
  store i8 %2, ptr %c.index, align 1
  %inc = add nsw i32 %idx, 1
  %exitcond = icmp eq i32 %idx, %bound
  br i1 %exitcond, label %for.end, label %for.body, !prof !0

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

; If trip-count is equal to 10, the function is vectorised when predicated tail folding is chosen
define i32 @foo_mid_trip_count(ptr %a, ptr %b, ptr %c, i32 %bound) {
; CHECK-LABEL: @foo_mid_trip_count(
; PREDICATED: vector.body
; SCALAR-NOT: vector.body
entry:
  br label %for.body

for.body:                                         ; preds = %for.body, %entry
  %idx = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %a.index = getelementptr inbounds [32 x i8], ptr %a, i32 0, i32 %idx
  %0 = load i8, ptr %a.index, align 1
  %b.index = getelementptr inbounds [32 x i8], ptr %b, i32 0, i32 %idx
  %1 = load i8, ptr %b.index, align 1
  %2 = add i8 %0, %1
  %c.index = getelementptr inbounds [32 x i8], ptr %c, i32 0, i32 %idx
  store i8 %2, ptr %c.index, align 1
  %inc = add nsw i32 %idx, 1
  %exitcond = icmp eq i32 %idx, %bound
  br i1 %exitcond, label %for.end, label %for.body, !prof !1

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

; If trip-count is equal to 40, the function is always vectorised
define i32 @foo_high_trip_count(ptr %a, ptr %b, ptr %c, i32 %bound) {
; CHECK-LABEL: @foo_high_trip_count(
; PREDICATED: vector.body
; SCALAR: vector.body
entry:
  br label %for.body

for.body:                                         ; preds = %for.body, %entry
  %idx = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %a.index = getelementptr inbounds [32 x i8], ptr %a, i32 0, i32 %idx
  %0 = load i8, ptr %a.index, align 1
  %b.index = getelementptr inbounds [32 x i8], ptr %b, i32 0, i32 %idx
  %1 = load i8, ptr %b.index, align 1
  %2 = add i8 %0, %1
  %c.index = getelementptr inbounds [32 x i8], ptr %c, i32 0, i32 %idx
  store i8 %2, ptr %c.index, align 1
  %inc = add nsw i32 %idx, 1
  %exitcond = icmp eq i32 %idx, %bound
  br i1 %exitcond, label %for.end, label %for.body, !prof !2

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

!0 = !{!"branch_weights", i32 10, i32 30}
!1 = !{!"branch_weights", i32 10, i32 90}
!2 = !{!"branch_weights", i32 10, i32 390}