Home | History | Annotate | Download | only in LoopVectorize
      1 ; RUN: opt -S -loop-vectorize < %s | FileCheck %s
      2 
      3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
      4 target triple = "x86_64-apple-macosx10.9.0"
      5 
      6 @a = global i32* null, align 8
      7 @b = global i32* null, align 8
      8 @c = global i32* null, align 8
      9 
     10 ; Don't create an exponetial IR for the edge masks needed when if-converting
     11 ; this code.
     12 
     13 ; PR16472
     14 
     15 ; CHECK-NOT: %6000000 =
     16 
     17 define void @_Z3fn4i(i32 %p1) {
     18 entry:
     19   %cmp88 = icmp sgt i32 %p1, 0
     20   br i1 %cmp88, label %for.body.lr.ph, label %for.end
     21 
     22 for.body.lr.ph:
     23   %0 = load i32*, i32** @b, align 8
     24   %1 = load i32*, i32** @a, align 8
     25   %2 = load i32*, i32** @c, align 8
     26   br label %for.body
     27 
     28 for.body:
     29   %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %_ZL3fn3ii.exit58 ]
     30   %arrayidx = getelementptr inbounds i32, i32* %0, i64 %indvars.iv
     31   %3 = load i32, i32* %arrayidx, align 4  %4 = trunc i64 %indvars.iv to i32
     32   %and.i = and i32 %4, 1
     33   %tobool.i.i = icmp eq i32 %and.i, 0
     34   br i1 %tobool.i.i, label %if.end.i, label %if.then.i
     35 
     36 if.then.i:
     37   %and.i.i = lshr i32 %3, 2
     38   %and.lobit.i.i = and i32 %and.i.i, 1
     39   %5 = xor i32 %and.lobit.i.i, 1
     40   %or.i.i = or i32 %5, %3
     41   %cmp.i = icmp sgt i32 %or.i.i, 0
     42   %conv.i = zext i1 %cmp.i to i32
     43   br label %if.end.i
     44 
     45 if.end.i:
     46   %tobool.i87 = phi i1 [ true, %if.then.i ], [ false, %for.body ]
     47   %p1.addr.0.i = phi i32 [ %conv.i, %if.then.i ], [ %3, %for.body ]
     48   %6 = trunc i64 %indvars.iv to i32
     49   %and1.i = and i32 %6, 7
     50   %tobool2.i = icmp eq i32 %and1.i, 0
     51   br i1 %tobool2.i, label %if.end7.i, label %if.then3.i
     52 
     53 if.then3.i:
     54   %p1.addr.0.lobit.i = lshr i32 %p1.addr.0.i, 31
     55   %and6.i = and i32 %p1.addr.0.i, 1
     56   %or.i = or i32 %p1.addr.0.lobit.i, %and6.i
     57   br label %if.end7.i
     58 
     59 if.end7.i:
     60   %p1.addr.1.i = phi i32 [ %or.i, %if.then3.i ], [ %p1.addr.0.i, %if.end.i ]
     61   br i1 %tobool.i87, label %if.then10.i, label %if.end13.i
     62 
     63 if.then10.i:
     64   %cmp11.i = icmp sgt i32 %p1.addr.1.i, 0
     65   %conv12.i = zext i1 %cmp11.i to i32
     66   br label %if.end13.i
     67 
     68 if.end13.i:
     69   %p1.addr.2.i = phi i32 [ %conv12.i, %if.then10.i ], [ %p1.addr.1.i, %if.end7.i ]
     70   br i1 %tobool.i.i, label %_Z3fn2iii.exit, label %if.then16.i
     71 
     72 if.then16.i:
     73   %and17.i = lshr i32 %p1.addr.2.i, 3
     74   %and17.lobit.i = and i32 %and17.i, 1
     75   br label %_Z3fn2iii.exit
     76 
     77 _Z3fn2iii.exit:
     78   %p1.addr.3.i = phi i32 [ %and17.lobit.i, %if.then16.i ], [ %p1.addr.2.i, %if.end13.i ]
     79   %7 = trunc i64 %indvars.iv to i32
     80   %shr.i = ashr i32 %7, 1
     81   %and.i18.i = and i32 %shr.i, 1
     82   %tobool.i19.i = icmp ne i32 %and.i18.i, 0
     83   br i1 %tobool.i19.i, label %if.then.i20.i, label %if.end.i.i
     84 
     85 if.then.i20.i:
     86   %cmp.i.i = icmp sgt i32 %p1.addr.3.i, 0
     87   %conv.i.i = zext i1 %cmp.i.i to i32
     88   br label %if.end.i.i
     89 
     90 if.end.i.i:
     91   %p1.addr.0.i21.i = phi i32 [ %conv.i.i, %if.then.i20.i ], [ %p1.addr.3.i, %_Z3fn2iii.exit ]
     92   %and1.i.i = and i32 %shr.i, 7
     93   %tobool2.i.i = icmp eq i32 %and1.i.i, 0
     94   br i1 %tobool2.i.i, label %if.end7.i.i, label %if.then3.i.i
     95 
     96 if.then3.i.i:
     97   %p1.addr.0.lobit.i.i = lshr i32 %p1.addr.0.i21.i, 31
     98   %and6.i.i = and i32 %p1.addr.0.i21.i, 1
     99   %or.i22.i = or i32 %p1.addr.0.lobit.i.i, %and6.i.i
    100   br label %if.end7.i.i
    101 
    102 if.end7.i.i:
    103   %p1.addr.1.i.i = phi i32 [ %or.i22.i, %if.then3.i.i ], [ %p1.addr.0.i21.i, %if.end.i.i ]
    104   br i1 %tobool.i19.i, label %if.then10.i.i, label %if.end13.i.i
    105 
    106 if.then10.i.i:
    107   %cmp11.i.i = icmp sgt i32 %p1.addr.1.i.i, 0
    108   %conv12.i.i = zext i1 %cmp11.i.i to i32
    109   br label %if.end13.i.i
    110 
    111 if.end13.i.i:
    112   %p1.addr.2.i.i = phi i32 [ %conv12.i.i, %if.then10.i.i ], [ %p1.addr.1.i.i, %if.end7.i.i ]
    113   %and14.i.i = and i32 %shr.i, 5
    114   %tobool15.i.i = icmp eq i32 %and14.i.i, 0
    115   br i1 %tobool15.i.i, label %_Z3fn2iii.exit.i, label %if.then16.i.i
    116 
    117 if.then16.i.i:
    118   %and17.i.i = lshr i32 %p1.addr.2.i.i, 3
    119   %and17.lobit.i.i = and i32 %and17.i.i, 1
    120   br label %_Z3fn2iii.exit.i
    121 
    122 _Z3fn2iii.exit.i:
    123   %p1.addr.3.i.i = phi i32 [ %and17.lobit.i.i, %if.then16.i.i ], [ %p1.addr.2.i.i, %if.end13.i.i ]
    124   %8 = trunc i64 %indvars.iv to i32
    125   %tobool.i11.i = icmp eq i32 %8, 0
    126   br i1 %tobool.i11.i, label %_ZL3fn3ii.exit, label %if.then.i15.i
    127 
    128 if.then.i15.i:
    129   %and.i12.i = lshr i32 %p1.addr.3.i.i, 2
    130   %and.lobit.i13.i = and i32 %and.i12.i, 1
    131   %9 = xor i32 %and.lobit.i13.i, 1
    132   %or.i14.i = or i32 %9, %p1.addr.3.i.i
    133   br label %_ZL3fn3ii.exit
    134 
    135 _ZL3fn3ii.exit:
    136   %p1.addr.0.i16.i = phi i32 [ %or.i14.i, %if.then.i15.i ], [ %p1.addr.3.i.i, %_Z3fn2iii.exit.i ]
    137   %arrayidx2 = getelementptr inbounds i32, i32* %1, i64 %indvars.iv
    138   store i32 %p1.addr.0.i16.i, i32* %arrayidx2, align 4  %arrayidx4 = getelementptr inbounds i32, i32* %0, i64 %indvars.iv
    139   %10 = load i32, i32* %arrayidx4, align 4  br i1 %tobool.i.i, label %_Z3fn1ii.exit.i26, label %if.then.i.i21
    140 
    141 if.then.i.i21:
    142   %and.i.i18 = lshr i32 %10, 2
    143   %and.lobit.i.i19 = and i32 %and.i.i18, 1
    144   %11 = xor i32 %and.lobit.i.i19, 1
    145   %or.i.i20 = or i32 %11, %10
    146   br label %_Z3fn1ii.exit.i26
    147 
    148 _Z3fn1ii.exit.i26:
    149   %p1.addr.0.i.i22 = phi i32 [ %or.i.i20, %if.then.i.i21 ], [ %10, %_ZL3fn3ii.exit ]
    150   br i1 %tobool.i87, label %if.then.i63, label %if.end.i67
    151 
    152 if.then.i63:
    153   %cmp.i61 = icmp sgt i32 %p1.addr.0.i.i22, 0
    154   %conv.i62 = zext i1 %cmp.i61 to i32
    155   br label %if.end.i67
    156 
    157 if.end.i67:
    158   %p1.addr.0.i64 = phi i32 [ %conv.i62, %if.then.i63 ], [ %p1.addr.0.i.i22, %_Z3fn1ii.exit.i26 ]
    159   br i1 %tobool2.i, label %if.end7.i73, label %if.then3.i71
    160 
    161 if.then3.i71:
    162   %p1.addr.0.lobit.i68 = lshr i32 %p1.addr.0.i64, 31
    163   %and6.i69 = and i32 %p1.addr.0.i64, 1
    164   %or.i70 = or i32 %p1.addr.0.lobit.i68, %and6.i69
    165   br label %if.end7.i73
    166 
    167 if.end7.i73:
    168   %p1.addr.1.i72 = phi i32 [ %or.i70, %if.then3.i71 ], [ %p1.addr.0.i64, %if.end.i67 ]
    169   br i1 %tobool.i87, label %if.then10.i76, label %if.end13.i80
    170 
    171 if.then10.i76:
    172   %cmp11.i74 = icmp sgt i32 %p1.addr.1.i72, 0
    173   %conv12.i75 = zext i1 %cmp11.i74 to i32
    174   br label %if.end13.i80
    175 
    176 if.end13.i80:
    177   %p1.addr.2.i77 = phi i32 [ %conv12.i75, %if.then10.i76 ], [ %p1.addr.1.i72, %if.end7.i73 ]
    178   br i1 %tobool.i.i, label %_Z3fn2iii.exit85, label %if.then16.i83
    179 
    180 if.then16.i83:
    181   %and17.i81 = lshr i32 %p1.addr.2.i77, 3
    182   %and17.lobit.i82 = and i32 %and17.i81, 1
    183   br label %_Z3fn2iii.exit85
    184 
    185 _Z3fn2iii.exit85:
    186   %p1.addr.3.i84 = phi i32 [ %and17.lobit.i82, %if.then16.i83 ], [ %p1.addr.2.i77, %if.end13.i80 ]
    187   br i1 %tobool.i19.i, label %if.then.i20.i29, label %if.end.i.i33
    188 
    189 if.then.i20.i29:
    190   %cmp.i.i27 = icmp sgt i32 %p1.addr.3.i84, 0
    191   %conv.i.i28 = zext i1 %cmp.i.i27 to i32
    192   br label %if.end.i.i33
    193 
    194 if.end.i.i33:
    195   %p1.addr.0.i21.i30 = phi i32 [ %conv.i.i28, %if.then.i20.i29 ], [ %p1.addr.3.i84, %_Z3fn2iii.exit85 ]
    196   br i1 %tobool2.i.i, label %if.end7.i.i39, label %if.then3.i.i37
    197 
    198 if.then3.i.i37:
    199   %p1.addr.0.lobit.i.i34 = lshr i32 %p1.addr.0.i21.i30, 31
    200   %and6.i.i35 = and i32 %p1.addr.0.i21.i30, 1
    201   %or.i22.i36 = or i32 %p1.addr.0.lobit.i.i34, %and6.i.i35
    202   br label %if.end7.i.i39
    203 
    204 if.end7.i.i39:
    205   %p1.addr.1.i.i38 = phi i32 [ %or.i22.i36, %if.then3.i.i37 ], [ %p1.addr.0.i21.i30, %if.end.i.i33 ]
    206   br i1 %tobool.i19.i, label %if.then10.i.i42, label %if.end13.i.i46
    207 
    208 if.then10.i.i42:
    209   %cmp11.i.i40 = icmp sgt i32 %p1.addr.1.i.i38, 0
    210   %conv12.i.i41 = zext i1 %cmp11.i.i40 to i32
    211   br label %if.end13.i.i46
    212 
    213 if.end13.i.i46:
    214   %p1.addr.2.i.i43 = phi i32 [ %conv12.i.i41, %if.then10.i.i42 ], [ %p1.addr.1.i.i38, %if.end7.i.i39 ]
    215   br i1 %tobool15.i.i, label %_Z3fn2iii.exit.i52, label %if.then16.i.i49
    216 
    217 if.then16.i.i49:
    218   %and17.i.i47 = lshr i32 %p1.addr.2.i.i43, 3
    219   %and17.lobit.i.i48 = and i32 %and17.i.i47, 1
    220   br label %_Z3fn2iii.exit.i52
    221 
    222 _Z3fn2iii.exit.i52:
    223   %p1.addr.3.i.i50 = phi i32 [ %and17.lobit.i.i48, %if.then16.i.i49 ], [ %p1.addr.2.i.i43, %if.end13.i.i46 ]
    224   br i1 %tobool.i11.i, label %_ZL3fn3ii.exit58, label %if.then.i15.i56
    225 
    226 if.then.i15.i56:
    227   %and.i12.i53 = lshr i32 %p1.addr.3.i.i50, 2
    228   %and.lobit.i13.i54 = and i32 %and.i12.i53, 1
    229   %12 = xor i32 %and.lobit.i13.i54, 1
    230   %or.i14.i55 = or i32 %12, %p1.addr.3.i.i50
    231   br label %_ZL3fn3ii.exit58
    232 
    233 _ZL3fn3ii.exit58:
    234   %p1.addr.0.i16.i57 = phi i32 [ %or.i14.i55, %if.then.i15.i56 ], [ %p1.addr.3.i.i50, %_Z3fn2iii.exit.i52 ]
    235   %arrayidx7 = getelementptr inbounds i32, i32* %2, i64 %indvars.iv
    236   store i32 %p1.addr.0.i16.i57, i32* %arrayidx7, align 4  %indvars.iv.next = add i64 %indvars.iv, 1
    237   %lftr.wideiv = trunc i64 %indvars.iv.next to i32
    238   %exitcond = icmp ne i32 %lftr.wideiv, %p1
    239   br i1 %exitcond, label %for.body, label %for.cond.for.end_crit_edge
    240 
    241 for.cond.for.end_crit_edge:
    242   br label %for.end
    243 
    244 for.end:
    245   ret void
    246 }
    247