1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt < %s -loop-reduce -S | FileCheck %s
4 ; Provide legal integer types.
5 target datalayout = "n8:16:32:64"
7 @d = common global i32 0, align 4
9 define void @fn2(i32 %x) nounwind uwtable {
10 ; CHECK-LABEL: define void @fn2(
11 ; CHECK-SAME: i32 [[X:%.*]]) #[[ATTR0:[0-9]+]] {
13 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
15 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi i32 [ [[LSR_IV_NEXT:%.*]], [[FOR_COND]] ], [ -1, [[ENTRY:%.*]] ]
16 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[X]], 0
17 ; CHECK-NEXT: [[LSR_IV_NEXT]] = add i32 [[LSR_IV]], 1
18 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[FOR_COND]], label [[FOR_END:%.*]]
20 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @d, align 4
21 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr @d, align 4
22 ; CHECK-NEXT: [[TMP0:%.*]] = sub i32 [[TMP1]], [[TMP2]]
23 ; CHECK-NEXT: [[TOBOOL26:%.*]] = icmp eq i32 [[X]], 0
24 ; CHECK-NEXT: br i1 [[TOBOOL26]], label [[FOR_END5:%.*]], label [[FOR_BODY_LR_PH:%.*]]
25 ; CHECK: for.body.lr.ph:
26 ; CHECK-NEXT: [[TOBOOL3:%.*]] = icmp ne i32 [[TMP0]], [[LSR_IV_NEXT]]
27 ; CHECK-NEXT: br label [[FOR_END5]]
29 ; CHECK-NEXT: ret void
35 %g.0 = phi i32 [ 0, %entry ], [ %dec, %for.cond ]
36 %tobool = icmp eq i32 %x, 0
37 %dec = add nsw i32 %g.0, -1
38 br i1 %tobool, label %for.cond, label %for.end
41 %tmp1 = load i32, ptr @d, align 4
42 %add = add nsw i32 %tmp1, %g.0
43 %tmp2 = load i32, ptr @d, align 4
44 %tobool26 = icmp eq i32 %x, 0
45 br i1 %tobool26, label %for.end5, label %for.body.lr.ph
48 %tobool3 = icmp ne i32 %tmp2, %add