File: pre-after-rle.ll

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (84 lines) | stat: -rw-r--r-- 2,421 bytes parent folder | download | duplicates (7)
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
; RUN: opt -phi-values -gvn -S < %s | FileCheck %s

declare noalias i8* @malloc(i64)

; Detecting that %s is fully redundant should let us detect that %w is partially
; redundant.
define void @fn1(i32** noalias %start, i32* %width, i32 %h) {
; CHECK-LABEL: @fn1
entry:
  %call = tail call noalias i8* @malloc(i64 1024)
  %call.cast = bitcast i8* %call to i32*
  store i32* %call.cast, i32** %start, align 8
  br label %preheader

preheader:
  %cmp = icmp slt i32 1, %h
  br i1 %cmp, label %body, label %exit

; CHECK-LABEL: preheader.body_crit_edge:
; CHECK: load i32, i32* %width, align 8

; CHECK-LABEL: body:
; CHECK-NOT: load i32*, i32** %start, align 8
; CHECK-NOT: load i32, i32* %width, align 8
body:
  %j = phi i32 [ 0, %preheader ], [ %j.next, %body ]
  %s = load i32*, i32** %start, align 8
  %idx = getelementptr inbounds i32, i32* %s, i64 0
  store i32 0, i32* %idx, align 4
  %j.next = add nuw nsw i32 %j, 1
  %w = load i32, i32* %width, align 8
  %cmp3 = icmp slt i32 %j.next, %w
  br i1 %cmp3, label %body, label %preheader

exit:
  ret void
}

; %s is fully redundant but has more than one available value. Detecting that
; %w is partially redundant requires alias analysis that can analyze those
; values.
define void @fn2(i32** noalias %start, i32* %width, i32 %h, i32 %arg) {
; CHECK-LABEL: @fn2
entry:
  %call = tail call noalias i8* @malloc(i64 1024)
  %call.cast = bitcast i8* %call to i32*
  %cmp1 = icmp slt i32 %arg, 0
  br i1 %cmp1, label %if, label %else

if:
  store i32* %call.cast, i32** %start, align 8
  br label %preheader

else:
  %gep = getelementptr inbounds i32, i32* %call.cast, i32 %arg
  store i32* %gep, i32** %start, align 8
  br label %preheader

; CHECK-LABEL: preheader:
; CHECK: %s = phi i32* [ %s, %body ], [ %gep, %else ], [ %call.cast, %if ]

preheader:
  %cmp = icmp slt i32 1, %h
  br i1 %cmp, label %body, label %exit

; CHECK-LABEL: preheader.body_crit_edge:
; CHECK: load i32, i32* %width, align 8

; CHECK-LABEL: body:
; CHECK-NOT: load i32*, i32** %start, align 8
; CHECK-NOT: load i32, i32* %width, align 8
body:
  %j = phi i32 [ 0, %preheader ], [ %j.next, %body ]
  %s = load i32*, i32** %start, align 8
  %idx = getelementptr inbounds i32, i32* %s, i64 0
  store i32 0, i32* %idx, align 4
  %j.next = add nuw nsw i32 %j, 1
  %w = load i32, i32* %width, align 8
  %cmp3 = icmp slt i32 %j.next, %w
  br i1 %cmp3, label %body, label %preheader

exit:
  ret void
}