Home | History | Annotate | Download | only in NewGVN
      1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
      2 ; RUN: opt < %s -basicaa -newgvn -enable-store-refinement -S | FileCheck %s
      3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
      4 
      5 ;; Both of these tests are tests of phi nodes that end up all equivalent to each other
      6 ;; Without proper leader ordering, we will end up cycling the leader between all of them and never converge.
      7 
      8 define void @foo() {
      9 ; CHECK-LABEL: @foo(
     10 ; CHECK-NEXT:  bb:
     11 ; CHECK-NEXT:    br label [[BB1:%.*]]
     12 ; CHECK:       bb1:
     13 ; CHECK-NEXT:    [[TMP:%.*]] = phi i32 [ 0, [[BB:%.*]] ], [ 1, [[BB18:%.*]] ]
     14 ; CHECK-NEXT:    br label [[BB2:%.*]]
     15 ; CHECK:       bb2:
     16 ; CHECK-NEXT:    br label [[BB4:%.*]]
     17 ; CHECK:       bb4:
     18 ; CHECK-NEXT:    br i1 undef, label [[BB18]], label [[BB7:%.*]]
     19 ; CHECK:       bb7:
     20 ; CHECK-NEXT:    br label [[BB9:%.*]]
     21 ; CHECK:       bb9:
     22 ; CHECK-NEXT:    br i1 undef, label [[BB2]], label [[BB11:%.*]]
     23 ; CHECK:       bb11:
     24 ; CHECK-NEXT:    br i1 undef, label [[BB16:%.*]], label [[BB14:%.*]]
     25 ; CHECK:       bb14:
     26 ; CHECK-NEXT:    br label [[BB4]]
     27 ; CHECK:       bb16:
     28 ; CHECK-NEXT:    br label [[BB7]]
     29 ; CHECK:       bb18:
     30 ; CHECK-NEXT:    br label [[BB1]]
     31 ;
     32 bb:
     33   br label %bb1
     34 
     35 bb1:                                              ; preds = %bb18, %bb
     36   %tmp = phi i32 [ 0, %bb ], [ 1, %bb18 ]
     37   br label %bb2
     38 
     39 bb2:                                              ; preds = %bb9, %bb1
     40   %tmp3 = phi i32 [ %tmp, %bb1 ], [ %tmp8, %bb9 ]
     41   br label %bb4
     42 
     43 bb4:                                              ; preds = %bb14, %bb2
     44   %tmp5 = phi i32 [ %tmp3, %bb2 ], [ %tmp15, %bb14 ]
     45   br i1 undef, label %bb18, label %bb7
     46 
     47 bb7:                                              ; preds = %bb16, %bb4
     48   %tmp8 = phi i32 [ %tmp17, %bb16 ], [ %tmp5, %bb4 ]
     49   br label %bb9
     50 
     51 bb9:                                              ; preds = %bb7
     52   br i1 undef, label %bb2, label %bb11
     53 
     54 bb11:                                             ; preds = %bb9
     55   br i1 undef, label %bb16, label %bb14
     56 
     57 bb14:                                             ; preds = %bb11
     58   %tmp15 = phi i32 [ %tmp8, %bb11 ]
     59   br label %bb4
     60 
     61 bb16:                                             ; preds = %bb11
     62   %tmp17 = phi i32 [ %tmp8, %bb11 ]
     63   br label %bb7
     64 
     65 bb18:                                             ; preds = %bb4
     66   br label %bb1
     67 }
     68 
     69 %struct.a = type {}
     70 %struct.b = type {}
     71 
     72 declare void @c.d.p(i64, i8*)
     73 
     74 define void @e() {
     75 ; CHECK-LABEL: @e(
     76 ; CHECK-NEXT:    [[F:%.*]] = alloca i32
     77 ; CHECK-NEXT:    store i32 undef, i32* [[F]], !g !0
     78 ; CHECK-NEXT:    br label [[H:%.*]]
     79 ; CHECK:       h:
     80 ; CHECK-NEXT:    call void @c.d.p(i64 8, i8* undef)
     81 ; CHECK-NEXT:    [[J:%.*]] = load i32, i32* null
     82 ; CHECK-NEXT:    br i1 true, label [[L:%.*]], label [[Q:%.*]]
     83 ; CHECK:       l:
     84 ; CHECK-NEXT:    br label [[R:%.*]]
     85 ; CHECK:       q:
     86 ; CHECK-NEXT:    store i8 undef, i8* null
     87 ; CHECK-NEXT:    br label [[R]]
     88 ; CHECK:       r:
     89 ; CHECK-NEXT:    switch i32 undef, label [[N:%.*]] [
     90 ; CHECK-NEXT:    i32 0, label [[S:%.*]]
     91 ; CHECK-NEXT:    ]
     92 ; CHECK:       s:
     93 ; CHECK-NEXT:    br label [[H]]
     94 ; CHECK:       n:
     95 ; CHECK-NEXT:    [[O:%.*]] = load %struct.a*, %struct.a** null
     96 ; CHECK-NEXT:    ret void
     97 ;
     98   %f = alloca i32
     99   store i32 undef, i32* %f, !g !0
    100   br label %h
    101 
    102 h:                                                ; preds = %s, %0
    103   call void @c.d.p(i64 8, i8* undef)
    104   %i = load i32, i32* %f
    105   %j = load i32, i32* null
    106   %k = icmp eq i32 %i, %j
    107   br i1 %k, label %l, label %q
    108 
    109 l:                                                ; preds = %h
    110   br label %r
    111 
    112 q:                                                ; preds = %h
    113   %m = load %struct.a*, %struct.a** null
    114   %1 = bitcast %struct.a* %m to %struct.b*
    115   br label %r
    116 
    117 r:                                                ; preds = %q, %l
    118   switch i32 undef, label %n [
    119   i32 0, label %s
    120   ]
    121 
    122 s:                                                ; preds = %r
    123   store i32 undef, i32* %f, !g !0
    124   br label %h
    125 
    126 n:                                                ; preds = %r
    127   %o = load %struct.a*, %struct.a** null
    128   %2 = bitcast %struct.a* %o to %struct.b*
    129   ret void
    130 }
    131 
    132 !0 = !{}
    133