reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
  211
  212
  213
  214
  215
  216
  217
  218
  219
  220
  221
  222
  223
  224
  225
  226
  227
  228
  229
  230
  231
  232
  233
  234
  235
  236
  237
  238
  239
  240
  241
  242
  243
  244
  245
  246
  247
  248
  249
  250
  251
  252
  253
  254
  255
  256
  257
  258
  259
  260
  261
  262
  263
  264
  265
  266
  267
  268
  269
  270
  271
  272
  273
  274
  275
  276
  277
  278
  279
  280
  281
  282
; RUN: opt < %s -passes='print<phi-values>' -disable-output 2>&1 | FileCheck %s

@X = common global i32 0

; CHECK-LABEL: PHI Values for function: simple
define void @simple(i32* %ptr) {
entry:
  br i1 undef, label %if, label %else

if:
  br label %end

else:
  br label %end

end:
; CHECK: PHI %phi1 has values:
; CHECK-DAG: i32 0
; CHECK-DAG: i32 1
  %phi1 = phi i32 [ 0, %if ], [ 1, %else ]
; CHECK: PHI %phi2 has values:
; CHECK-DAG: @X
; CHECK-DAG: %ptr
  %phi2 = phi i32* [ @X, %if ], [ %ptr, %else ]
  ret void
}

; CHECK-LABEL: PHI Values for function: chain
define void @chain() {
entry:
  br i1 undef, label %if1, label %else1

if1:
  br label %middle

else1:
  br label %middle

middle:
; CHECK: PHI %phi1 has values:
; CHECK-DAG: i32 0
; CHECK-DAG: i32 1
  %phi1 = phi i32 [ 0, %if1 ], [ 1, %else1 ]
  br i1 undef, label %if2, label %else2

if2:
  br label %end

else2:
  br label %end

end:
; CHECK: PHI %phi2 has values:
; CHECK-DAG: i32 0
; CHECK-DAG: i32 1
; CHECK-DAG: i32 2
  %phi2 = phi i32 [ %phi1, %if2 ], [ 2, %else2 ]
  ret void
}

; CHECK-LABEL: PHI Values for function: no_values
define void @no_values() {
entry:
  ret void

unreachable:
; CHECK: PHI %phi has values:
; CHECK-DAG: NONE
  %phi = phi i32 [ %phi, %unreachable ]
  br label %unreachable
}

; CHECK-LABEL: PHI Values for function: simple_loop
define void @simple_loop() {
entry:
  br label %loop

loop:
; CHECK: PHI %phi has values:
; CHECK-DAG: i32 0
  %phi = phi i32 [ 0, %entry ], [ %phi, %loop ]
  br i1 undef, label %loop, label %end

end:
  ret void
}

; CHECK-LABEL: PHI Values for function: complex_loop
define void @complex_loop() {
entry:
  br i1 undef, label %loop, label %end

loop:
; CHECK: PHI %phi1 has values:
; CHECK-DAG: i32 0
; CHECK-DAG: i32 1
  %phi1 = phi i32 [ 0, %entry ], [ %phi2, %then ]
  br i1 undef, label %if, label %else

if:
  br label %then

else:
  br label %then

then:
; CHECK: PHI %phi2 has values:
; CHECK-DAG: i32 0
; CHECK-DAG: i32 1
  %phi2 = phi i32 [ %phi1, %if ], [ 1, %else ]
  br i1 undef, label %loop, label %end

end:
; CHECK: PHI %phi3 has values:
; CHECK-DAG: i32 0
; CHECK-DAG: i32 1
; CHECK-DAG: i32 2
  %phi3 = phi i32 [ 2, %entry ], [ %phi2, %then ]
  ret void
}

; CHECK-LABEL: PHI Values for function: strange_loop
define void @strange_loop() {
entry:
  br i1 undef, label %ifelse, label %inloop

loop:
; CHECK: PHI %phi1 has values:
; CHECK-DAG: i32 0
; CHECK-DAG: i32 1
; CHECK-DAG: i32 2
; CHECK-DAG: i32 3
  %phi1 = phi i32 [ %phi3, %if ], [ 0, %else ], [ %phi2, %inloop ]
  br i1 undef, label %inloop, label %end

inloop:
; CHECK: PHI %phi2 has values:
; CHECK-DAG: i32 0
; CHECK-DAG: i32 1
; CHECK-DAG: i32 2
; CHECK-DAG: i32 3
  %phi2 = phi i32 [ %phi1, %loop ], [ 1, %entry ]
  br i1 undef, label %ifelse, label %loop

ifelse:
; CHECK: PHI %phi3 has values:
; CHECK-DAG: i32 2
; CHECK-DAG: i32 3
  %phi3 = phi i32 [ 2, %entry ], [ 3, %inloop ]
  br i1 undef, label %if, label %else

if:
  br label %loop

else:
  br label %loop

end:
  ret void
}

; CHECK-LABEL: PHI Values for function: mutual_loops
define void @mutual_loops() {
entry:
  br i1 undef, label %loop1, label %loop2

loop1:
; CHECK: PHI %phi1 has values:
; CHECK-DAG: 0
; CHECK-DAG: 1
; CHECK-DAG: 2
; CHECK-DAG: 3
; CHECK-DAG: 4
  %phi1 = phi i32 [ 0, %entry ], [ %phi2, %loop1.then ], [ %phi3, %loop2.if ]
  br i1 undef, label %loop1.if, label %loop1.else

loop1.if:
  br i1 undef, label %loop1.then, label %loop2

loop1.else:
  br label %loop1.then

loop1.then:
; CHECK: PHI %phi2 has values:
; CHECK-DAG: 0
; CHECK-DAG: 1
; CHECK-DAG: 2
; CHECK-DAG: 3
; CHECK-DAG: 4
  %phi2 = phi i32 [ 1, %loop1.if ], [ %phi1, %loop1.else ]
  br i1 undef, label %loop1, label %end

loop2:
; CHECK: PHI %phi3 has values:
; CHECK-DAG: 2
; CHECK-DAG: 3
; CHECK-DAG: 4
  %phi3 = phi i32 [ 2, %entry ], [ %phi4, %loop2.then ], [ 3, %loop1.if ]
  br i1 undef, label %loop2.if, label %loop2.else

loop2.if:
  br i1 undef, label %loop2.then, label %loop1

loop2.else:
  br label %loop2.then

loop2.then:
; CHECK: PHI %phi4 has values:
; CHECK-DAG: 2
; CHECK-DAG: 3
; CHECK-DAG: 4
  %phi4 = phi i32 [ 4, %loop2.if ], [ %phi3, %loop2.else ]
  br i1 undef, label %loop2, label %end

end:
; CHECK: PHI %phi5 has values:
; CHECK-DAG: 0
; CHECK-DAG: 1
; CHECK-DAG: 2
; CHECK-DAG: 3
; CHECK-DAG: 4
  %phi5 = phi i32 [ %phi2, %loop1.then ], [ %phi4, %loop2.then ]
  ret void
}

; CHECK-LABEL: PHI Values for function: nested_loops_several_values
define void @nested_loops_several_values() {
entry:
  br label %loop1

loop1:
; CHECK: PHI %phi1 has values:
; CHECK-DAG: i32 0
; CHECK-DAG: %add
  %phi1 = phi i32 [ 0, %entry ], [ %phi2, %loop2 ]
  br i1 undef, label %loop2, label %end

loop2:
; CHECK: PHI %phi2 has values:
; CHECK-DAG: i32 0
; CHECK-DAG: %add
  %phi2 = phi i32 [ %phi1, %loop1 ], [ %phi3, %loop3 ]
  br i1 undef, label %loop3, label %loop1

loop3:
; CHECK: PHI %phi3 has values:
; CHECK-DAG: i32 0
; CHECK-DAG: %add
  %phi3 = phi i32 [ %add, %loop3 ], [ %phi2, %loop2 ]
  %add = add i32 %phi3, 1
  br i1 undef, label %loop3, label %loop2

end:
  ret void
}

; CHECK-LABEL: PHI Values for function: nested_loops_one_value
define void @nested_loops_one_value() {
entry:
  br label %loop1

loop1:
; CHECK: PHI %phi1 has values:
; CHECK-DAG: i32 0
  %phi1 = phi i32 [ 0, %entry ], [ %phi2, %loop2 ]
  br i1 undef, label %loop2, label %end

loop2:
; CHECK: PHI %phi2 has values:
; CHECK-DAG: i32 0
  %phi2 = phi i32 [ %phi1, %loop1 ], [ %phi3, %loop3 ]
  br i1 undef, label %loop3, label %loop1

loop3:
; CHECK: PHI %phi3 has values:
; CHECK-DAG: i32 0
  %phi3 = phi i32 [ 0, %loop3 ], [ %phi2, %loop2 ]
  br i1 undef, label %loop3, label %loop2

end:
  ret void
}