File: runtime-check-size-based-threshold.ll

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-6~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,418,812 kB
  • sloc: cpp: 5,290,827; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,900; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,892; xml: 953; cs: 573; fortran: 539
file content (111 lines) | stat: -rw-r--r-- 4,230 bytes parent folder | download | duplicates (3)
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
109
110
111
; RUN: opt -loop-vectorize -mtriple=arm64-apple-iphoneos -S %s | FileCheck %s

; Tests for loops with large numbers of runtime checks. Check that loops are
; vectorized, if the loop trip counts are large and the impact of the runtime
; checks is very small compared to the expected loop runtimes.


; The trip count in the loop in this function is too to warrant large runtime checks.
; CHECK-LABEL: define {{.*}} @test_tc_too_small
; CHECK-NOT: vector.memcheck
; CHECK-NOT: vector.body
define void @test_tc_too_small(i16* %ptr.1, i16* %ptr.2, i16* %ptr.3, i16* %ptr.4, i64 %off.1, i64 %off.2) {
entry:
  br label %loop

loop:                                             ; preds = %bb54, %bb37
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
  %gep.1 = getelementptr inbounds i16, i16* %ptr.1, i64 %iv
  %lv.1 = load i16, i16* %gep.1, align 2
  %ext.1 = sext i16 %lv.1 to i32
  %gep.2 = getelementptr inbounds i16, i16* %ptr.2, i64 %iv
  %lv.2 = load i16, i16* %gep.2, align 2
  %ext.2 = sext i16 %lv.2 to i32
  %gep.off.1 = getelementptr inbounds i16, i16* %gep.2, i64 %off.1
  %lv.3 = load i16, i16* %gep.off.1, align 2
  %ext.3 = sext i16 %lv.3 to i32
  %gep.off.2 = getelementptr inbounds i16, i16* %gep.2, i64 %off.2
  %lv.4 = load i16, i16* %gep.off.2, align 2
  %ext.4 = sext i16 %lv.4 to i32
  %tmp62 = mul nsw i32 %ext.2, 11
  %tmp66 = mul nsw i32 %ext.3, -4
  %tmp70 = add nsw i32 %tmp62, 4
  %tmp71 = add nsw i32 %tmp70, %tmp66
  %tmp72 = add nsw i32 %tmp71, %ext.4
  %tmp73 = lshr i32 %tmp72, 3
  %tmp74 = add nsw i32 %tmp73, %ext.1
  %tmp75 = lshr i32 %tmp74, 1
  %tmp76 = mul nsw i32 %ext.2, 5
  %tmp77 = shl nsw i32 %ext.3, 2
  %tmp78 = add nsw i32 %tmp76, 4
  %tmp79 = add nsw i32 %tmp78, %tmp77
  %tmp80 = sub nsw i32 %tmp79, %ext.4
  %tmp81 = lshr i32 %tmp80, 3
  %tmp82 = sub nsw i32 %tmp81, %ext.1
  %tmp83 = lshr i32 %tmp82, 1
  %trunc.1 = trunc i32 %tmp75 to i16
  %gep.3 = getelementptr inbounds i16, i16* %ptr.3, i64 %iv
  store i16 %trunc.1, i16* %gep.3, align 2
  %trunc.2 = trunc i32 %tmp83 to i16
  %gep.4 = getelementptr inbounds i16, i16* %ptr.4, i64 %iv
  store i16 %trunc.2, i16* %gep.4, align 2
  %iv.next = add nuw nsw i64 %iv, 1
  %cmp = icmp ult i64 %iv, 50
  br i1 %cmp, label %loop, label %exit

exit:
  ret void
}

; FIXME
; The trip count in the loop in this function high enough to warrant large runtime checks.
; CHECK-LABEL: define {{.*}} @test_tc_big_enough
; CHECK-NOT: vector.memcheck
; CHECK-NOT: vector.body
define void @test_tc_big_enough(i16* %ptr.1, i16* %ptr.2, i16* %ptr.3, i16* %ptr.4, i64 %off.1, i64 %off.2) {
entry:
  br label %loop

loop:                                             ; preds = %bb54, %bb37
  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
  %gep.1 = getelementptr inbounds i16, i16* %ptr.1, i64 %iv
  %lv.1 = load i16, i16* %gep.1, align 2
  %ext.1 = sext i16 %lv.1 to i32
  %gep.2 = getelementptr inbounds i16, i16* %ptr.2, i64 %iv
  %lv.2 = load i16, i16* %gep.2, align 2
  %ext.2 = sext i16 %lv.2 to i32
  %gep.off.1 = getelementptr inbounds i16, i16* %gep.2, i64 %off.1
  %lv.3 = load i16, i16* %gep.off.1, align 2
  %ext.3 = sext i16 %lv.3 to i32
  %gep.off.2 = getelementptr inbounds i16, i16* %gep.2, i64 %off.2
  %lv.4 = load i16, i16* %gep.off.2, align 2
  %ext.4 = sext i16 %lv.4 to i32
  %tmp62 = mul nsw i32 %ext.2, 11
  %tmp66 = mul nsw i32 %ext.3, -4
  %tmp70 = add nsw i32 %tmp62, 4
  %tmp71 = add nsw i32 %tmp70, %tmp66
  %tmp72 = add nsw i32 %tmp71, %ext.4
  %tmp73 = lshr i32 %tmp72, 3
  %tmp74 = add nsw i32 %tmp73, %ext.1
  %tmp75 = lshr i32 %tmp74, 1
  %tmp76 = mul nsw i32 %ext.2, 5
  %tmp77 = shl nsw i32 %ext.3, 2
  %tmp78 = add nsw i32 %tmp76, 4
  %tmp79 = add nsw i32 %tmp78, %tmp77
  %tmp80 = sub nsw i32 %tmp79, %ext.4
  %tmp81 = lshr i32 %tmp80, 3
  %tmp82 = sub nsw i32 %tmp81, %ext.1
  %tmp83 = lshr i32 %tmp82, 1
  %trunc.1 = trunc i32 %tmp75 to i16
  %gep.3 = getelementptr inbounds i16, i16* %ptr.3, i64 %iv
  store i16 %trunc.1, i16* %gep.3, align 2
  %trunc.2 = trunc i32 %tmp83 to i16
  %gep.4 = getelementptr inbounds i16, i16* %ptr.4, i64 %iv
  store i16 %trunc.2, i16* %gep.4, align 2
  %iv.next = add nuw nsw i64 %iv, 1
  %cmp = icmp ult i64 %iv, 500
  br i1 %cmp, label %loop, label %exit

exit:
  ret void
}