File: rewrite-undef-for-phi.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (103 lines) | stat: -rw-r--r-- 2,940 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
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -mtriple=amdgcn-- -S -amdgpu-rewrite-undef-for-phi %s | FileCheck -check-prefix=OPT %s

define amdgpu_ps float @basic(float inreg %c, i32 %x) #0 {
; OPT-LABEL: @basic(
; OPT-NEXT:  entry:
; OPT-NEXT:    [[CC:%.*]] = icmp slt i32 [[X:%.*]], 0
; OPT-NEXT:    br i1 [[CC]], label [[IF:%.*]], label [[END:%.*]]
; OPT:       if:
; OPT-NEXT:    br label [[END]]
; OPT:       end:
; OPT-NEXT:    ret float [[C:%.*]]
;
entry:
  %cc = icmp slt i32 %x, 0
  br i1 %cc, label %if, label %end

if:
  br label %end

end:
  %c2 = phi float [ undef, %if ], [ %c, %entry ]
  ret float %c2
}

define amdgpu_ps float @with_uniform_region_inside(float inreg %c, i32 inreg %d, i32 %x) #0 {
; OPT-LABEL: @with_uniform_region_inside(
; OPT-NEXT:  entry:
; OPT-NEXT:    [[CC:%.*]] = icmp slt i32 [[X:%.*]], 0
; OPT-NEXT:    br i1 [[CC]], label [[IF:%.*]], label [[END:%.*]]
; OPT:       if:
; OPT-NEXT:    [[CC2:%.*]] = icmp slt i32 [[D:%.*]], 0
; OPT-NEXT:    br i1 [[CC2]], label [[BB2:%.*]], label [[BB3:%.*]]
; OPT:       bb2:
; OPT-NEXT:    br label [[END]]
; OPT:       bb3:
; OPT-NEXT:    [[CC3:%.*]] = icmp slt i32 [[D]], 2
; OPT-NEXT:    br i1 [[CC3]], label [[BB4:%.*]], label [[END]]
; OPT:       bb4:
; OPT-NEXT:    br label [[END]]
; OPT:       end:
; OPT-NEXT:    ret float [[C:%.*]]
;
entry:
  %cc = icmp slt i32 %x, 0
  br i1 %cc, label %if, label %end

if:
  %cc2 = icmp slt i32 %d, 0
  br i1 %cc2, label %bb2, label %bb3

bb2:
  br label %end

bb3:
  %cc3 = icmp slt i32 %d, 2
  br i1 %cc3, label %bb4, label %end

bb4:
  br label %end

end:
  %c2 = phi float [ undef, %bb2 ], [ %c, %bb3 ], [ undef, %bb4 ], [ %c, %entry ]
  ret float %c2
}

define amdgpu_ps float @exclude_backedge(float inreg %c, i32 %x) #0 {
; OPT-LABEL: @exclude_backedge(
; OPT-NEXT:  entry:
; OPT-NEXT:    [[CC:%.*]] = icmp slt i32 [[X:%.*]], 0
; OPT-NEXT:    br i1 [[CC]], label [[END:%.*]], label [[LOOP:%.*]]
; OPT:       loop:
; OPT-NEXT:    [[IND:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[LOOP]] ]
; OPT-NEXT:    [[C2:%.*]] = phi float [ [[C:%.*]], [[ENTRY]] ], [ undef, [[LOOP]] ]
; OPT-NEXT:    [[INC]] = add i32 [[IND]], 1
; OPT-NEXT:    [[LOOP_CC:%.*]] = icmp slt i32 [[INC]], 5
; OPT-NEXT:    br i1 [[LOOP_CC]], label [[LOOP]], label [[LOOP_END:%.*]]
; OPT:       loop_end:
; OPT-NEXT:    br label [[END]]
; OPT:       end:
; OPT-NEXT:    [[R:%.*]] = phi float [ [[C2]], [[LOOP_END]] ], [ [[C]], [[ENTRY]] ]
; OPT-NEXT:    ret float [[R]]
;
entry:
  %cc = icmp slt i32 %x, 0
  br i1 %cc, label %end, label %loop

loop:
  %ind = phi i32 [ 0, %entry ], [ %inc, %loop ]
  %c2 = phi float [ %c, %entry ], [ undef, %loop ]
  %inc = add i32 %ind, 1
  %loop_cc = icmp slt i32 %inc, 5
  br i1 %loop_cc, label %loop, label %loop_end

loop_end:
  br label %end

end:
  %r = phi float [ %c2, %loop_end ], [ %c, %entry ]
  ret float %r
}

attributes #0 = { nounwind noinline }