1 ; RUN: opt < %s -loop-reduce -S | FileCheck %s 2 3 @d = common global i32 0, align 4 4 5 define void @fn2(i32 %x) nounwind uwtable { 6 entry: 7 br label %for.cond 8 9 for.cond: 10 %g.0 = phi i32 [ 0, %entry ], [ %dec, %for.cond ] 11 %tobool = icmp eq i32 %x, 0 12 %dec = add nsw i32 %g.0, -1 13 br i1 %tobool, label %for.cond, label %for.end 14 15 for.end: 16 ; CHECK: %tmp1 = load i32* @d, align 4 17 ; CHECK-NEXT: %tmp2 = load i32* @d, align 4 18 ; CHECK-NEXT: %0 = sub i32 %tmp1, %tmp2 19 20 %tmp1 = load i32* @d, align 4 21 %add = add nsw i32 %tmp1, %g.0 22 %tmp2 = load i32* @d, align 4 23 %tobool26 = icmp eq i32 %x, 0 24 br i1 %tobool26, label %for.end5, label %for.body.lr.ph 25 26 for.body.lr.ph: 27 %tobool3 = icmp ne i32 %tmp2, %add 28 br label %for.end5 29 30 for.end5: 31 ret void 32 } 33 34 35