1 ; RUN: llc < %s -O3 -march=x86-64 -mcpu=core2 | FileCheck %s 2 3 declare i1 @check() nounwind 4 declare i1 @foo(i8*, i8*, i8*) nounwind 5 6 ; Check that redundant phi elimination ran 7 ; CHECK: @test 8 ; CHECK: %while.body.i 9 ; CHECK: movs 10 ; CHECK-NOT: movs 11 ; CHECK: %for.end.i 12 define i32 @test(i8* %base) nounwind uwtable ssp { 13 entry: 14 br label %while.body.lr.ph.i 15 16 while.body.lr.ph.i: ; preds = %cond.true.i 17 br label %while.body.i 18 19 while.body.i: ; preds = %cond.true29.i, %while.body.lr.ph.i 20 %indvars.iv7.i = phi i64 [ 16, %while.body.lr.ph.i ], [ %indvars.iv.next8.i, %cond.true29.i ] 21 %i.05.i = phi i64 [ 0, %while.body.lr.ph.i ], [ %indvars.iv7.i, %cond.true29.i ] 22 %sext.i = shl i64 %i.05.i, 32 23 %idx.ext.i = ashr exact i64 %sext.i, 32 24 %add.ptr.sum.i = add i64 %idx.ext.i, 16 25 br label %for.body.i 26 27 for.body.i: ; preds = %for.body.i, %while.body.i 28 %indvars.iv.i = phi i64 [ 0, %while.body.i ], [ %indvars.iv.next.i, %for.body.i ] 29 %add.ptr.sum = add i64 %add.ptr.sum.i, %indvars.iv.i 30 %arrayidx22.i = getelementptr inbounds i8* %base, i64 %add.ptr.sum 31 %0 = load i8* %arrayidx22.i, align 1 32 %indvars.iv.next.i = add i64 %indvars.iv.i, 1 33 %cmp = call i1 @check() nounwind 34 br i1 %cmp, label %for.end.i, label %for.body.i 35 36 for.end.i: ; preds = %for.body.i 37 %add.ptr.i144 = getelementptr inbounds i8* %base, i64 %add.ptr.sum.i 38 %cmp2 = tail call i1 @foo(i8* %add.ptr.i144, i8* %add.ptr.i144, i8* undef) nounwind 39 br i1 %cmp2, label %cond.true29.i, label %cond.false35.i 40 41 cond.true29.i: ; preds = %for.end.i 42 %indvars.iv.next8.i = add i64 %indvars.iv7.i, 16 43 br i1 false, label %exit, label %while.body.i 44 45 cond.false35.i: ; preds = %for.end.i 46 unreachable 47 48 exit: ; preds = %cond.true29.i, %cond.true.i 49 ret i32 0 50 } 51 52 %struct.anon.7.91.199.307.415.475.559.643.751.835.943.1003.1111.1219.1351.1375.1399.1435.1471.1483.1519.1531.1651.1771 = type { i32, i32, i32 } 53 54 @tags = external global [5000 x %struct.anon.7.91.199.307.415.475.559.643.751.835.943.1003.1111.1219.1351.1375.1399.1435.1471.1483.1519.1531.1651.1771], align 16 55 56 ; PR11782: SCEVExpander assert 57 ; 58 ; Test phi reuse after LSR that requires SCEVExpander to hoist an 59 ; interesting GEP. 60 ; 61 ; CHECK: @test2 62 ; CHECK: %entry 63 ; CHECK-NOT: mov 64 ; CHECK: je 65 define void @test2(i32 %n) nounwind uwtable { 66 entry: 67 br i1 undef, label %while.end, label %for.cond468 68 69 for.cond468: ; preds = %if.then477, %entry 70 %indvars.iv1163 = phi i64 [ %indvars.iv.next1164, %if.then477 ], [ 1, %entry ] 71 %k.0.in = phi i32* [ %last, %if.then477 ], [ getelementptr inbounds ([5000 x %struct.anon.7.91.199.307.415.475.559.643.751.835.943.1003.1111.1219.1351.1375.1399.1435.1471.1483.1519.1531.1651.1771]* @tags, i64 0, i64 0, i32 2), %entry ] 72 %k.0 = load i32* %k.0.in, align 4 73 %0 = trunc i64 %indvars.iv1163 to i32 74 %cmp469 = icmp slt i32 %0, %n 75 br i1 %cmp469, label %for.body471, label %for.inc498 76 77 for.body471: ; preds = %for.cond468 78 %first = getelementptr inbounds [5000 x %struct.anon.7.91.199.307.415.475.559.643.751.835.943.1003.1111.1219.1351.1375.1399.1435.1471.1483.1519.1531.1651.1771]* @tags, i64 0, i64 %indvars.iv1163, i32 1 79 %1 = load i32* %first, align 4 80 br i1 undef, label %if.then477, label %for.inc498 81 82 if.then477: ; preds = %for.body471 83 %last = getelementptr inbounds [5000 x %struct.anon.7.91.199.307.415.475.559.643.751.835.943.1003.1111.1219.1351.1375.1399.1435.1471.1483.1519.1531.1651.1771]* @tags, i64 0, i64 %indvars.iv1163, i32 2 84 %indvars.iv.next1164 = add i64 %indvars.iv1163, 1 85 br label %for.cond468 86 87 for.inc498: ; preds = %for.inc498, %for.body471, %for.cond468 88 br label %for.inc498 89 90 while.end: ; preds = %entry 91 ret void 92 } 93