Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -mtriple=x86_64-apple-macosx -regalloc=greedy | FileCheck %s
      2 
      3 ; This testing case is reduced from 197.parser prune_match function.
      4 ; We make sure register copies are not generated on isupper.exit blocks.
      5 
      6 ; isupper.exit and isupper.exit223 get tail-duplicated into all their
      7 ; predecessors.
      8 ; CHECK: cond.true.i.i
      9 ; CHECK-NEXT: in Loop
     10 ; Mem-move
     11 ; CHECK-NEXT: movl
     12 ; CHECK-NEXT: andl
     13 ; CHECK-NEXT: testl
     14 ; CHECK-NEXT: jne
     15 ; CHECK: cond.true.i.i217
     16 ; CHECK-NEXT: in Loop
     17 ; Mem-move
     18 ; CHECK-NEXT: movl
     19 ; CHECK-NEXT: andl
     20 ; CHECK-NEXT: testl
     21 ; CHECK-NEXT: je
     22 ; CHECK: cond.false.i.i
     23 ; CHECK: maskrune
     24 ; CHECK-NEXT: movzbl
     25 ; CHECK-NEXT: movzbl
     26 ; CHECK-NEXT: testl
     27 ; CHECK-NEXT: je
     28 ; CHECK: cond.false.i.i219
     29 ; CHECK: maskrune
     30 ; CHECK-NEXT: movzbl
     31 ; CHECK-NEXT: movzbl
     32 ; CHECK-NEXT: testl
     33 ; CHECK-NEXT: jne
     34 
     35 %struct.List_o_links_struct = type { i32, i32, i32, %struct.List_o_links_struct* }
     36 %struct.Connector_struct = type { i16, i16, i8, i8, %struct.Connector_struct*, i8* }
     37 %struct._RuneLocale = type { [8 x i8], [32 x i8], i32 (i8*, i64, i8**)*, i32 (i32, i8*, i64, i8**)*, i32, [256 x i32], [256 x i32], [256 x i32], %struct._RuneRange, %struct._RuneRange, %struct._RuneRange, i8*, i32, i32, %struct._RuneCharClass* }
     38 %struct._RuneRange = type { i32, %struct._RuneEntry* }
     39 %struct._RuneEntry = type { i32, i32, i32, i32* }
     40 %struct._RuneCharClass = type { [14 x i8], i32 }
     41 %struct.Exp_struct = type { i8, i8, i8, i8, %union.anon }
     42 %union.anon = type { %struct.E_list_struct* }
     43 %struct.E_list_struct = type { %struct.E_list_struct*, %struct.Exp_struct* }
     44 %struct.domain_struct = type { i8*, i32, %struct.List_o_links_struct*, i32, i32, %struct.d_tree_leaf_struct*, %struct.domain_struct* }
     45 %struct.d_tree_leaf_struct = type { %struct.domain_struct*, i32, %struct.d_tree_leaf_struct* }
     46 @_DefaultRuneLocale = external global %struct._RuneLocale
     47 declare i32 @__maskrune(i32, i64) #7
     48 define fastcc i32 @prune_match(%struct.Connector_struct* nocapture readonly %a, %struct.Connector_struct* nocapture readonly %b) #9 {
     49 entry:
     50   %label56 = bitcast %struct.Connector_struct* %a to i16*
     51   %0 = load i16, i16* %label56, align 2
     52   %label157 = bitcast %struct.Connector_struct* %b to i16*
     53   %1 = load i16, i16* %label157, align 2
     54   %cmp = icmp eq i16 %0, %1
     55   br i1 %cmp, label %if.end, label %return, !prof !988
     56 if.end:
     57   %priority = getelementptr inbounds %struct.Connector_struct, %struct.Connector_struct* %a, i64 0, i32 2
     58   %2 = load i8, i8* %priority, align 1
     59   %priority5 = getelementptr inbounds %struct.Connector_struct, %struct.Connector_struct* %b, i64 0, i32 2
     60   %3 = load i8, i8* %priority5, align 1
     61   %string = getelementptr inbounds %struct.Connector_struct, %struct.Connector_struct* %a, i64 0, i32 5
     62   %4 = load i8*, i8** %string, align 8
     63   %string7 = getelementptr inbounds %struct.Connector_struct, %struct.Connector_struct* %b, i64 0, i32 5
     64   %5 = load i8*, i8** %string7, align 8
     65   br label %while.cond
     66 while.cond:
     67   %lsr.iv27 = phi i64 [ %lsr.iv.next28, %if.end17 ], [ 0, %if.end ]
     68   %scevgep55 = getelementptr i8, i8* %4, i64 %lsr.iv27
     69   %6 = load i8, i8* %scevgep55, align 1
     70   %idxprom.i.i = sext i8 %6 to i64
     71   %isascii.i.i224 = icmp sgt i8 %6, -1
     72   br i1 %isascii.i.i224, label %cond.true.i.i, label %cond.false.i.i, !prof !181
     73 cond.true.i.i:
     74   %arrayidx.i.i = getelementptr inbounds %struct._RuneLocale, %struct._RuneLocale* @_DefaultRuneLocale, i64 0, i32 5, i64 %idxprom.i.i
     75   %7 = load i32, i32* %arrayidx.i.i, align 4
     76   %and.i.i = and i32 %7, 32768
     77   br label %isupper.exit
     78 cond.false.i.i:
     79   %8 = trunc i64 %idxprom.i.i to i8
     80   %conv8 = sext i8 %8 to i32
     81   %call3.i.i = tail call i32 @__maskrune(i32 %conv8, i64 32768) #3
     82   br label %isupper.exit
     83 isupper.exit:
     84   %tobool1.sink.i.in.i = phi i32 [ %and.i.i, %cond.true.i.i ], [ %call3.i.i, %cond.false.i.i ]
     85   %tobool1.sink.i.i = icmp eq i32 %tobool1.sink.i.in.i, 0
     86   br i1 %tobool1.sink.i.i, label %lor.rhs, label %while.body, !prof !989
     87 lor.rhs:
     88   %sunkaddr = ptrtoint i8* %5 to i64
     89   %sunkaddr58 = add i64 %sunkaddr, %lsr.iv27
     90   %sunkaddr59 = inttoptr i64 %sunkaddr58 to i8*
     91   %9 = load i8, i8* %sunkaddr59, align 1
     92   %idxprom.i.i214 = sext i8 %9 to i64
     93   %isascii.i.i213225 = icmp sgt i8 %9, -1
     94   br i1 %isascii.i.i213225, label %cond.true.i.i217, label %cond.false.i.i219, !prof !181
     95 cond.true.i.i217:
     96   %arrayidx.i.i215 = getelementptr inbounds %struct._RuneLocale, %struct._RuneLocale* @_DefaultRuneLocale, i64 0, i32 5, i64 %idxprom.i.i214
     97   %10 = load i32, i32* %arrayidx.i.i215, align 4
     98   %and.i.i216 = and i32 %10, 32768
     99   br label %isupper.exit223
    100 cond.false.i.i219:
    101   %11 = trunc i64 %idxprom.i.i214 to i8
    102   %conv9 = sext i8 %11 to i32
    103   %call3.i.i218 = tail call i32 @__maskrune(i32 %conv9, i64 32768) #3
    104   br label %isupper.exit223
    105 isupper.exit223:
    106   %tobool1.sink.i.in.i220 = phi i32 [ %and.i.i216, %cond.true.i.i217 ], [ %call3.i.i218, %cond.false.i.i219 ]
    107   %tobool1.sink.i.i221 = icmp eq i32 %tobool1.sink.i.in.i220, 0
    108   br i1 %tobool1.sink.i.i221, label %while.end, label %while.body, !prof !990
    109 while.body:
    110   %sunkaddr60 = ptrtoint i8* %4 to i64
    111   %sunkaddr61 = add i64 %sunkaddr60, %lsr.iv27
    112   %sunkaddr62 = inttoptr i64 %sunkaddr61 to i8*
    113   %12 = load i8, i8* %sunkaddr62, align 1
    114   %sunkaddr63 = ptrtoint i8* %5 to i64
    115   %sunkaddr64 = add i64 %sunkaddr63, %lsr.iv27
    116   %sunkaddr65 = inttoptr i64 %sunkaddr64 to i8*
    117   %13 = load i8, i8* %sunkaddr65, align 1
    118   %cmp14 = icmp eq i8 %12, %13
    119   br i1 %cmp14, label %if.end17, label %return, !prof !991
    120 if.end17:
    121   %lsr.iv.next28 = add i64 %lsr.iv27, 1
    122   br label %while.cond
    123 while.end:
    124   %14 = or i8 %3, %2
    125   %15 = icmp eq i8 %14, 0
    126   br i1 %15, label %if.then23, label %if.else88, !prof !992
    127 if.then23:
    128   %sunkaddr66 = ptrtoint %struct.Connector_struct* %a to i64
    129   %sunkaddr67 = add i64 %sunkaddr66, 16
    130   %sunkaddr68 = inttoptr i64 %sunkaddr67 to i8**
    131   %16 = load i8*, i8** %sunkaddr68, align 8
    132   %17 = load i8, i8* %16, align 1
    133   %cmp26 = icmp eq i8 %17, 83
    134   %sunkaddr69 = ptrtoint i8* %4 to i64
    135   %sunkaddr70 = add i64 %sunkaddr69, %lsr.iv27
    136   %sunkaddr71 = inttoptr i64 %sunkaddr70 to i8*
    137   %18 = load i8, i8* %sunkaddr71, align 1
    138   br i1 %cmp26, label %land.lhs.true28, label %while.cond59.preheader, !prof !993
    139 land.lhs.true28:
    140   switch i8 %18, label %land.rhs.preheader [
    141     i8 112, label %land.lhs.true35
    142     i8 0, label %return
    143   ], !prof !994
    144 land.lhs.true35:
    145   %sunkaddr72 = ptrtoint i8* %5 to i64
    146   %sunkaddr73 = add i64 %sunkaddr72, %lsr.iv27
    147   %sunkaddr74 = inttoptr i64 %sunkaddr73 to i8*
    148   %19 = load i8, i8* %sunkaddr74, align 1
    149   switch i8 %19, label %land.rhs.preheader [
    150     i8 112, label %land.lhs.true43
    151   ], !prof !995
    152 land.lhs.true43:
    153   %20 = ptrtoint i8* %16 to i64
    154   %21 = sub i64 0, %20
    155   %scevgep52 = getelementptr i8, i8* %4, i64 %21
    156   %scevgep53 = getelementptr i8, i8* %scevgep52, i64 %lsr.iv27
    157   %scevgep54 = getelementptr i8, i8* %scevgep53, i64 -1
    158   %cmp45 = icmp eq i8* %scevgep54, null
    159   br i1 %cmp45, label %return, label %lor.lhs.false47, !prof !996
    160 lor.lhs.false47:
    161   %22 = ptrtoint i8* %16 to i64
    162   %23 = sub i64 0, %22
    163   %scevgep47 = getelementptr i8, i8* %4, i64 %23
    164   %scevgep48 = getelementptr i8, i8* %scevgep47, i64 %lsr.iv27
    165   %scevgep49 = getelementptr i8, i8* %scevgep48, i64 -2
    166   %cmp50 = icmp eq i8* %scevgep49, null
    167   br i1 %cmp50, label %land.lhs.true52, label %while.cond59.preheader, !prof !997
    168 land.lhs.true52:
    169   %sunkaddr75 = ptrtoint i8* %4 to i64
    170   %sunkaddr76 = add i64 %sunkaddr75, %lsr.iv27
    171   %sunkaddr77 = add i64 %sunkaddr76, -1
    172   %sunkaddr78 = inttoptr i64 %sunkaddr77 to i8*
    173   %24 = load i8, i8* %sunkaddr78, align 1
    174   %cmp55 = icmp eq i8 %24, 73
    175   %cmp61233 = icmp eq i8 %18, 0
    176   %or.cond265 = or i1 %cmp55, %cmp61233
    177   br i1 %or.cond265, label %return, label %land.rhs.preheader, !prof !998
    178 while.cond59.preheader:
    179   %cmp61233.old = icmp eq i8 %18, 0
    180   br i1 %cmp61233.old, label %return, label %land.rhs.preheader, !prof !999
    181 land.rhs.preheader:
    182   %scevgep33 = getelementptr i8, i8* %5, i64 %lsr.iv27
    183   %scevgep43 = getelementptr i8, i8* %4, i64 %lsr.iv27
    184   br label %land.rhs
    185 land.rhs:
    186   %lsr.iv = phi i64 [ 0, %land.rhs.preheader ], [ %lsr.iv.next, %if.then83 ]
    187   %25 = phi i8 [ %27, %if.then83 ], [ %18, %land.rhs.preheader ]
    188   %scevgep34 = getelementptr i8, i8* %scevgep33, i64 %lsr.iv
    189   %26 = load i8, i8* %scevgep34, align 1
    190   %cmp64 = icmp eq i8 %26, 0
    191   br i1 %cmp64, label %return, label %while.body66, !prof !1000
    192 while.body66:
    193   %cmp68 = icmp eq i8 %25, 42
    194   %cmp72 = icmp eq i8 %26, 42
    195   %or.cond = or i1 %cmp68, %cmp72
    196   br i1 %or.cond, label %if.then83, label %lor.lhs.false74, !prof !1001
    197 lor.lhs.false74:
    198   %cmp77 = icmp ne i8 %25, %26
    199   %cmp81 = icmp eq i8 %25, 94
    200   %or.cond208 = or i1 %cmp77, %cmp81
    201   br i1 %or.cond208, label %return, label %if.then83, !prof !1002
    202 if.then83:
    203   %scevgep44 = getelementptr i8, i8* %scevgep43, i64 %lsr.iv
    204   %scevgep45 = getelementptr i8, i8* %scevgep44, i64 1
    205   %27 = load i8, i8* %scevgep45, align 1
    206   %cmp61 = icmp eq i8 %27, 0
    207   %lsr.iv.next = add i64 %lsr.iv, 1
    208   br i1 %cmp61, label %return, label %land.rhs, !prof !999
    209 if.else88:
    210   %cmp89 = icmp eq i8 %2, 1
    211   %cmp92 = icmp eq i8 %3, 2
    212   %or.cond159 = and i1 %cmp89, %cmp92
    213   br i1 %or.cond159, label %while.cond95.preheader, label %if.else123, !prof !1003
    214 while.cond95.preheader:
    215   %sunkaddr79 = ptrtoint i8* %4 to i64
    216   %sunkaddr80 = add i64 %sunkaddr79, %lsr.iv27
    217   %sunkaddr81 = inttoptr i64 %sunkaddr80 to i8*
    218   %28 = load i8, i8* %sunkaddr81, align 1
    219   %cmp97238 = icmp eq i8 %28, 0
    220   br i1 %cmp97238, label %return, label %land.rhs99.preheader, !prof !1004
    221 land.rhs99.preheader:
    222   %scevgep31 = getelementptr i8, i8* %5, i64 %lsr.iv27
    223   %scevgep40 = getelementptr i8, i8* %4, i64 %lsr.iv27
    224   br label %land.rhs99
    225 land.rhs99:
    226   %lsr.iv17 = phi i64 [ 0, %land.rhs99.preheader ], [ %lsr.iv.next18, %if.then117 ]
    227   %29 = phi i8 [ %31, %if.then117 ], [ %28, %land.rhs99.preheader ]
    228   %scevgep32 = getelementptr i8, i8* %scevgep31, i64 %lsr.iv17
    229   %30 = load i8, i8* %scevgep32, align 1
    230   %cmp101 = icmp eq i8 %30, 0
    231   br i1 %cmp101, label %return, label %while.body104, !prof !1005
    232 while.body104:
    233   %cmp107 = icmp eq i8 %29, %30
    234   %cmp111 = icmp eq i8 %29, 42
    235   %or.cond209 = or i1 %cmp107, %cmp111
    236   %cmp115 = icmp eq i8 %30, 94
    237   %or.cond210 = or i1 %or.cond209, %cmp115
    238   br i1 %or.cond210, label %if.then117, label %return, !prof !1006
    239 if.then117:
    240   %scevgep41 = getelementptr i8, i8* %scevgep40, i64 %lsr.iv17
    241   %scevgep42 = getelementptr i8, i8* %scevgep41, i64 1
    242   %31 = load i8, i8* %scevgep42, align 1
    243   %cmp97 = icmp eq i8 %31, 0
    244   %lsr.iv.next18 = add i64 %lsr.iv17, 1
    245   br i1 %cmp97, label %return, label %land.rhs99, !prof !1004
    246 if.else123:
    247   %cmp124 = icmp eq i8 %3, 1
    248   %cmp127 = icmp eq i8 %2, 2
    249   %or.cond160 = and i1 %cmp124, %cmp127
    250   br i1 %or.cond160, label %while.cond130.preheader, label %return, !prof !1007
    251 while.cond130.preheader:
    252   %sunkaddr82 = ptrtoint i8* %4 to i64
    253   %sunkaddr83 = add i64 %sunkaddr82, %lsr.iv27
    254   %sunkaddr84 = inttoptr i64 %sunkaddr83 to i8*
    255   %32 = load i8, i8* %sunkaddr84, align 1
    256   %cmp132244 = icmp eq i8 %32, 0
    257   br i1 %cmp132244, label %return, label %land.rhs134.preheader, !prof !1008
    258 land.rhs134.preheader:
    259   %scevgep29 = getelementptr i8, i8* %5, i64 %lsr.iv27
    260   %scevgep37 = getelementptr i8, i8* %4, i64 %lsr.iv27
    261   br label %land.rhs134
    262 land.rhs134:
    263   %lsr.iv22 = phi i64 [ 0, %land.rhs134.preheader ], [ %lsr.iv.next23, %if.then152 ]
    264   %33 = phi i8 [ %35, %if.then152 ], [ %32, %land.rhs134.preheader ]
    265   %scevgep30 = getelementptr i8, i8* %scevgep29, i64 %lsr.iv22
    266   %34 = load i8, i8* %scevgep30, align 1
    267   %cmp136 = icmp eq i8 %34, 0
    268   br i1 %cmp136, label %return, label %while.body139, !prof !1009
    269 while.body139:
    270   %cmp142 = icmp eq i8 %33, %34
    271   %cmp146 = icmp eq i8 %34, 42
    272   %or.cond211 = or i1 %cmp142, %cmp146
    273   %cmp150 = icmp eq i8 %33, 94
    274   %or.cond212 = or i1 %or.cond211, %cmp150
    275   br i1 %or.cond212, label %if.then152, label %return, !prof !1010
    276 if.then152:
    277   %scevgep38 = getelementptr i8, i8* %scevgep37, i64 %lsr.iv22
    278   %scevgep39 = getelementptr i8, i8* %scevgep38, i64 1
    279   %35 = load i8, i8* %scevgep39, align 1
    280   %cmp132 = icmp eq i8 %35, 0
    281   %lsr.iv.next23 = add i64 %lsr.iv22, 1
    282   br i1 %cmp132, label %return, label %land.rhs134, !prof !1008
    283 return:
    284   %retval.0 = phi i32 [ 0, %entry ], [ 1, %land.lhs.true52 ], [ 1, %land.lhs.true43 ], [ 0, %if.else123 ], [ 1, %while.cond59.preheader ], [ 1, %while.cond95.preheader ], [ 1, %while.cond130.preheader ], [ 1, %land.lhs.true28 ], [ 1, %if.then83 ], [ 0, %lor.lhs.false74 ], [ 1, %land.rhs ], [ 1, %if.then117 ], [ 0, %while.body104 ], [ 1, %land.rhs99 ], [ 1, %if.then152 ], [ 0, %while.body139 ], [ 1, %land.rhs134 ], [ 0, %while.body ]
    285   ret i32 %retval.0
    286 }
    287 !181 = !{!"branch_weights", i32 662038, i32 1}
    288 !988 = !{!"branch_weights", i32 12091450, i32 1916}
    289 !989 = !{!"branch_weights", i32 7564670, i32 4526781}
    290 !990 = !{!"branch_weights", i32 7484958, i32 13283499}
    291 !991 = !{!"branch_weights", i32 8677007, i32 4606493}
    292 !992 = !{!"branch_weights", i32 -1172426948, i32 145094705}
    293 !993 = !{!"branch_weights", i32 1468914, i32 5683688}
    294 !994 = !{!"branch_weights", i32 114025221, i32 -1217548794, i32 -1199521551, i32 87712616}
    295 !995 = !{!"branch_weights", i32 1853716452, i32 -444717951, i32 932776759}
    296 !996 = !{!"branch_weights", i32 1004870, i32 20259}
    297 !997 = !{!"branch_weights", i32 20071, i32 189}
    298 !998 = !{!"branch_weights", i32 -1020255939, i32 572177766}
    299 !999 = !{!"branch_weights", i32 2666513, i32 3466431}
    300 !1000 = !{!"branch_weights", i32 5117635, i32 1859780}
    301 !1001 = !{!"branch_weights", i32 354902465, i32 -1444604407}
    302 !1002 = !{!"branch_weights", i32 -1762419279, i32 1592770684}
    303 !1003 = !{!"branch_weights", i32 1435905930, i32 -1951930624}
    304 !1004 = !{!"branch_weights", i32 1, i32 504888}
    305 !1005 = !{!"branch_weights", i32 94662, i32 504888}
    306 !1006 = !{!"branch_weights", i32 -1897793104, i32 160196332}
    307 !1007 = !{!"branch_weights", i32 2074643678, i32 -29579071}
    308 !1008 = !{!"branch_weights", i32 1, i32 226163}
    309 !1009 = !{!"branch_weights", i32 58357, i32 226163}
    310 !1010 = !{!"branch_weights", i32 -2072848646, i32 92907517}
    311