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