1 ; RUN: opt -loop-reduce -S < %s | FileCheck %s
3 ; Test LSR's use of SplitCriticalEdge during phi rewriting.
5 target triple = "x86_64-apple-darwin"
7 ; Provide legal integer types.
8 target datalayout = "n8:16:32:64"
11 ; Verify that identical edges are merged. rdar://problem/6453893
12 ; CHECK-LABEL: @test1(
14 ; CHECK: phi i8* [ %lsr.iv.next1, %bbA.bb89_crit_edge ], [ %lsr.iv.next1, %bbB.bb89_crit_edge ]{{$}}
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
27 br i1 false, label %bbA, label %bbB
30 switch i32 0, label %bb89 [
36 switch i8 0, label %bb89 [
42 %tmp75phi = phi i8* [ %tmp75, %bbA ], [ %tmp75, %bbA ], [ %tmp75, %bbA ], [ %tmp75, %bbB ], [ %tmp75, %bbB ], [ %tmp75, %bbB ]
49 ; Handle single-predecessor phis: PR13756
50 ; CHECK-LABEL: @test2(
52 ; CHECK: phi i8* [ %lsr.iv.next1, %bbA ], [ %lsr.iv.next1, %bbA ], [ %lsr.iv.next1, %bbA ]{{$}}
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
64 br i1 false, label %bbA, label %bbB
67 switch i32 0, label %bb89 [
73 switch i8 0, label %exit [
79 %tmp75phi = phi i8* [ %tmp75, %bbA ], [ %tmp75, %bbA ], [ %tmp75, %bbA ]
83 %result = phi i8* [ %tmp75phi, %bb89 ], [ %tmp75, %bbB ], [ %tmp75, %bbB ], [ %tmp75, %bbB ]