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