• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -loop-reduce -S < %s | FileCheck %s
2;
3; Test LSR's use of SplitCriticalEdge during phi rewriting.
4
5target triple = "x86-apple-darwin"
6
7; Provide legal integer types.
8target datalayout = "n8:16:32:64"
9
10
11; Verify that identical edges are merged. rdar://problem/6453893
12; CHECK-LABEL: @test1(
13; CHECK: bb89:
14; CHECK: phi i8* [ %lsr.iv.next1, %bbA.bb89_crit_edge ], [ %lsr.iv.next1, %bbB.bb89_crit_edge ]{{$}}
15
16define i8* @test1() {
17entry:
18  br label %loop
19
20loop:
21  %rec = phi i32 [ %next, %loop ], [ 0, %entry ]
22  %next = add i32 %rec, 1
23  %tmp75 = getelementptr i8, i8* null, i32 %next
24  br i1 false, label %loop, label %loopexit
25
26loopexit:
27  br i1 false, label %bbA, label %bbB
28
29bbA:
30  switch i32 0, label %bb89 [
31    i32 47, label %bb89
32    i32 58, label %bb89
33  ]
34
35bbB:
36  switch i8 0, label %bb89 [
37    i8 47, label %bb89
38    i8 58, label %bb89
39  ]
40
41bb89:
42  %tmp75phi = phi i8* [ %tmp75, %bbA ], [ %tmp75, %bbA ], [ %tmp75, %bbA ], [ %tmp75, %bbB ], [ %tmp75, %bbB ], [ %tmp75, %bbB ]
43  br label %exit
44
45exit:
46  ret i8* %tmp75phi
47}
48
49; Handle single-predecessor phis: PR13756
50; CHECK-LABEL: @test2(
51; CHECK: bb89:
52; CHECK: phi i8* [ %lsr.iv.next1, %bbA ], [ %lsr.iv.next1, %bbA ], [ %lsr.iv.next1, %bbA ]{{$}}
53define i8* @test2() {
54entry:
55  br label %loop
56
57loop:
58  %rec = phi i32 [ %next, %loop ], [ 0, %entry ]
59  %next = add i32 %rec, 1
60  %tmp75 = getelementptr i8, i8* null, i32 %next
61  br i1 false, label %loop, label %loopexit
62
63loopexit:
64  br i1 false, label %bbA, label %bbB
65
66bbA:
67  switch i32 0, label %bb89 [
68    i32 47, label %bb89
69    i32 58, label %bb89
70  ]
71
72bbB:
73  switch i8 0, label %exit [
74    i8 47, label %exit
75    i8 58, label %exit
76  ]
77
78bb89:
79  %tmp75phi = phi i8* [ %tmp75, %bbA ], [ %tmp75, %bbA ], [ %tmp75, %bbA ]
80  br label %exit
81
82exit:
83  %result = phi i8* [ %tmp75phi, %bb89 ], [ %tmp75, %bbB ], [ %tmp75, %bbB ], [ %tmp75, %bbB ]
84  ret i8* %result
85}
86