Home | History | Annotate | Download | only in LCSSA
      1 ; RUN: opt < %s -lcssa -S -o - | FileCheck %s
      2 target triple = "x86_64-unknown-linux-gnu"
      3 
      4 ; PR28424
      5 ; Here LCSSA adds phi-nodes for %x into the loop exits. Then, SSAUpdater needs
      6 ; to insert phi-nodes to merge these values. That creates a new def, which in
      7 ; its turn needs another LCCSA phi-node, and this test ensures that we insert
      8 ; it.
      9 
     10 ; CHECK-LABEL: @foo1
     11 define internal i32 @foo1() {
     12 entry:
     13   br label %header
     14 
     15 header:
     16   %x = add i32 0, 1
     17   br i1 undef, label %if, label %loopexit1
     18 
     19 if:
     20   br i1 undef, label %latch, label %loopexit2
     21 
     22 latch:
     23   br i1 undef, label %header, label %loopexit3
     24 
     25 ; CHECK: loopexit1:
     26 ; CHECK:   %x.lcssa = phi i32 [ %x, %header ]
     27 loopexit1:
     28   br label %loop_with_insert_point
     29 
     30 ; CHECK: loopexit2:
     31 ; CHECK:   %x.lcssa1 = phi i32 [ %x, %if ]
     32 loopexit2:
     33   br label %exit
     34 
     35 ; CHECK: loopexit3:
     36 ; CHECK:   %x.lcssa2 = phi i32 [ %x, %latch ]
     37 loopexit3:
     38   br label %loop_with_insert_point
     39 
     40 ; CHECK: loop_with_insert_point:
     41 ; CHECK:   %x4 = phi i32 [ %x4, %loop_with_insert_point ], [ %x.lcssa2, %loopexit3 ], [ %x.lcssa, %loopexit1 ]
     42 loop_with_insert_point:
     43   br i1 undef, label %loop_with_insert_point, label %bb
     44 
     45 ; CHECK: bb:
     46 ; CHECK:   %x4.lcssa = phi i32 [ %x4, %loop_with_insert_point ]
     47 bb:
     48   br label %exit
     49 
     50 ; CHECK: exit:
     51 ; CHECK:   %x3 = phi i32 [ %x4.lcssa, %bb ], [ %x.lcssa1, %loopexit2 ]
     52 exit:
     53   ret i32 %x
     54 }
     55 
     56 ; CHECK-LABEL: @foo2
     57 define internal i32 @foo2() {
     58 entry:
     59   br label %header
     60 
     61 header:
     62   %x = add i32 0, 1
     63   br i1 undef, label %latch, label %loopexit1
     64 
     65 latch:
     66   br i1 undef, label %header, label %loopexit2
     67 
     68 ; CHECK: loopexit1:
     69 ; CHECK:   %x.lcssa = phi i32 [ %x, %header ]
     70 loopexit1:
     71   br label %loop_with_insert_point
     72 
     73 ; CHECK: loopexit2:
     74 ; CHECK:   %x.lcssa1 = phi i32 [ %x, %latch ]
     75 loopexit2:
     76   br label %loop_with_insert_point
     77 
     78 ; CHECK: loop_with_insert_point:
     79 ; CHECK:   %x2 = phi i32 [ %x2, %loop_with_insert_point ], [ %x.lcssa1, %loopexit2 ], [ %x.lcssa, %loopexit1 ]
     80 loop_with_insert_point:
     81   br i1 undef, label %loop_with_insert_point, label %exit
     82 
     83 ; CHECK: exit:
     84 ; CHECK:   %x2.lcssa = phi i32 [ %x2, %loop_with_insert_point ]
     85 exit:
     86   ret i32 %x
     87 }
     88