File: pr28424.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,696 kB
  • sloc: cpp: 7,438,781; ansic: 1,393,871; asm: 1,012,926; python: 241,771; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 8,596; ml: 5,082; perl: 4,730; makefile: 3,591; awk: 3,523; javascript: 2,251; xml: 892; fortran: 672
file content (87 lines) | stat: -rw-r--r-- 2,123 bytes parent folder | download | duplicates (5)
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
; RUN: opt < %s -passes=lcssa -S -o - | FileCheck %s
target triple = "x86_64-unknown-linux-gnu"

; PR28424
; Here LCSSA adds phi-nodes for %x into the loop exits. Then, SSAUpdater needs
; to insert phi-nodes to merge these values. That creates a new def, which in
; its turn needs another LCCSA phi-node, and this test ensures that we insert
; it.

; CHECK-LABEL: @foo1
define internal i32 @foo1(i1 %arg) {
entry:
  br label %header

header:
  %x = add i32 0, 1
  br i1 %arg, label %if, label %loopexit1

if:
  br i1 %arg, label %latch, label %loopexit2

latch:
  br i1 %arg, label %header, label %loopexit3

; CHECK: loopexit1:
; CHECK:   %x.lcssa = phi i32 [ %x, %header ]
loopexit1:
  br label %loop_with_insert_point

; CHECK: loopexit2:
; CHECK:   %x.lcssa1 = phi i32 [ %x, %if ]
loopexit2:
  br label %exit

; CHECK: loopexit3:
; CHECK:   %x.lcssa2 = phi i32 [ %x, %latch ]
loopexit3:
  br label %loop_with_insert_point

; CHECK: loop_with_insert_point:
; CHECK:   %x4 = phi i32 [ %x4, %loop_with_insert_point ], [ %x.lcssa2, %loopexit3 ], [ %x.lcssa, %loopexit1 ]
loop_with_insert_point:
  br i1 %arg, label %loop_with_insert_point, label %bb

; CHECK: bb:
; CHECK:   %x4.lcssa = phi i32 [ %x4, %loop_with_insert_point ]
bb:
  br label %exit

; CHECK: exit:
; CHECK:   %x3 = phi i32 [ %x4.lcssa, %bb ], [ %x.lcssa1, %loopexit2 ]
exit:
  ret i32 %x
}

; CHECK-LABEL: @foo2
define internal i32 @foo2(i1 %arg) {
entry:
  br label %header

header:
  %x = add i32 0, 1
  br i1 %arg, label %latch, label %loopexit1

latch:
  br i1 %arg, label %header, label %loopexit2

; CHECK: loopexit1:
; CHECK:   %x.lcssa = phi i32 [ %x, %header ]
loopexit1:
  br label %loop_with_insert_point

; CHECK: loopexit2:
; CHECK:   %x.lcssa1 = phi i32 [ %x, %latch ]
loopexit2:
  br label %loop_with_insert_point

; CHECK: loop_with_insert_point:
; CHECK:   %x2 = phi i32 [ %x2, %loop_with_insert_point ], [ %x.lcssa1, %loopexit2 ], [ %x.lcssa, %loopexit1 ]
loop_with_insert_point:
  br i1 %arg, label %loop_with_insert_point, label %exit

; CHECK: exit:
; CHECK:   %x2.lcssa = phi i32 [ %x2, %loop_with_insert_point ]
exit:
  ret i32 %x
}