1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes='hardware-loops<force-hardware-loops;hardware-loop-decrement=1;hardware-loop-counter-bitwidth=32>' -S | FileCheck %s
4 define arm_aapcs_vfpcc void @test(ptr noalias nocapture readonly %off, ptr noalias nocapture %data, ptr noalias nocapture %dst, i32 %n) {
7 ; CHECK-NEXT: [[CMP252:%.*]] = icmp sgt i32 [[N:%.*]], 0
8 ; CHECK-NEXT: br i1 [[CMP252]], label [[FOR_COND1_PREHEADER_US:%.*]], label [[FOR_COND_CLEANUP:%.*]]
9 ; CHECK: for.cond1.preheader.us:
10 ; CHECK-NEXT: [[I_057_US:%.*]] = phi i32 [ [[INC29_US:%.*]], [[FOR_COND_CLEANUP14_US:%.*]] ], [ 0, [[ENTRY:%.*]] ]
11 ; CHECK-NEXT: [[MUL_US:%.*]] = mul i32 [[I_057_US]], [[N]]
12 ; CHECK-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]])
13 ; CHECK-NEXT: br label [[FOR_BODY4_US:%.*]]
14 ; CHECK: for.body4.us:
15 ; CHECK-NEXT: [[J_053_US:%.*]] = phi i32 [ 0, [[FOR_COND1_PREHEADER_US]] ], [ [[INC_US:%.*]], [[FOR_BODY4_US]] ]
16 ; CHECK-NEXT: [[ARRAYIDX_US:%.*]] = getelementptr inbounds i16, ptr [[OFF:%.*]], i32 [[J_053_US]]
17 ; CHECK-NEXT: [[L2:%.*]] = load i16, ptr [[ARRAYIDX_US]], align 2
18 ; CHECK-NEXT: [[ARRAYIDX5_US:%.*]] = getelementptr inbounds i16, ptr [[DATA:%.*]], i32 [[J_053_US]]
19 ; CHECK-NEXT: [[L3:%.*]] = load i16, ptr [[ARRAYIDX5_US]], align 2
20 ; CHECK-NEXT: [[ADD_US:%.*]] = add i16 [[L3]], [[L2]]
21 ; CHECK-NEXT: [[ADD8_US:%.*]] = add i32 [[J_053_US]], [[MUL_US]]
22 ; CHECK-NEXT: [[ARRAYIDX9_US:%.*]] = getelementptr inbounds i16, ptr [[DATA]], i32 [[ADD8_US]]
23 ; CHECK-NEXT: store i16 [[ADD_US]], ptr [[ARRAYIDX9_US]], align 2
24 ; CHECK-NEXT: [[INC_US]] = add nuw nsw i32 [[J_053_US]], 1
25 ; CHECK-NEXT: [[TMP0:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1)
26 ; CHECK-NEXT: br i1 [[TMP0]], label [[FOR_BODY4_US]], label [[FOR_BODY15_US_PREHEADER:%.*]]
27 ; CHECK: for.body15.us.preheader:
28 ; CHECK-NEXT: [[J10_055_US_PH:%.*]] = phi i32 [ 0, [[FOR_BODY4_US]] ]
29 ; CHECK-NEXT: call void @llvm.set.loop.iterations.i32(i32 [[N]])
30 ; CHECK-NEXT: br label [[FOR_BODY15_US:%.*]]
31 ; CHECK: for.body15.us:
32 ; CHECK-NEXT: [[J10_055_US:%.*]] = phi i32 [ [[INC26_US:%.*]], [[FOR_BODY15_US]] ], [ [[J10_055_US_PH]], [[FOR_BODY15_US_PREHEADER]] ]
33 ; CHECK-NEXT: [[ARRAYIDX16_US:%.*]] = getelementptr inbounds i16, ptr [[OFF]], i32 [[J10_055_US]]
34 ; CHECK-NEXT: [[L0:%.*]] = load i16, ptr [[ARRAYIDX16_US]], align 2
35 ; CHECK-NEXT: [[ARRAYIDX18_US:%.*]] = getelementptr inbounds i16, ptr [[DATA]], i32 [[J10_055_US]]
36 ; CHECK-NEXT: [[L1:%.*]] = load i16, ptr [[ARRAYIDX18_US]], align 2
37 ; CHECK-NEXT: [[ADD20_US:%.*]] = add i16 [[L1]], [[L0]]
38 ; CHECK-NEXT: [[ADD23_US:%.*]] = add i32 [[J10_055_US]], [[MUL_US]]
39 ; CHECK-NEXT: [[ARRAYIDX24_US:%.*]] = getelementptr inbounds i16, ptr [[DST:%.*]], i32 [[ADD23_US]]
40 ; CHECK-NEXT: store i16 [[ADD20_US]], ptr [[ARRAYIDX24_US]], align 2
41 ; CHECK-NEXT: [[INC26_US]] = add nuw nsw i32 [[J10_055_US]], 1
42 ; CHECK-NEXT: [[TMP1:%.*]] = call i1 @llvm.loop.decrement.i32(i32 1)
43 ; CHECK-NEXT: br i1 [[TMP1]], label [[FOR_BODY15_US]], label [[FOR_COND_CLEANUP14_US]]
44 ; CHECK: for.cond.cleanup14.us:
45 ; CHECK-NEXT: [[INC29_US]] = add nuw i32 [[I_057_US]], 1
46 ; CHECK-NEXT: [[EXITCOND94:%.*]] = icmp eq i32 [[INC29_US]], [[N]]
47 ; CHECK-NEXT: br i1 [[EXITCOND94]], label [[FOR_COND_CLEANUP]], label [[FOR_COND1_PREHEADER_US]]
48 ; CHECK: for.cond.cleanup:
49 ; CHECK-NEXT: ret void
52 %cmp252 = icmp sgt i32 %n, 0
53 br i1 %cmp252, label %for.cond1.preheader.us, label %for.cond.cleanup
55 for.cond1.preheader.us: ; preds = %entry, %for.cond.cleanup14.us
56 %i.057.us = phi i32 [ %inc29.us, %for.cond.cleanup14.us ], [ 0, %entry ]
57 %mul.us = mul i32 %i.057.us, %n
58 br label %for.body4.us
60 for.body4.us: ; preds = %for.body4.us, %for.cond1.preheader.us
61 %j.053.us = phi i32 [ 0, %for.cond1.preheader.us ], [ %inc.us, %for.body4.us ]
62 %arrayidx.us = getelementptr inbounds i16, ptr %off, i32 %j.053.us
63 %l2 = load i16, ptr %arrayidx.us, align 2
64 %arrayidx5.us = getelementptr inbounds i16, ptr %data, i32 %j.053.us
65 %l3 = load i16, ptr %arrayidx5.us, align 2
66 %add.us = add i16 %l3, %l2
67 %add8.us = add i32 %j.053.us, %mul.us
68 %arrayidx9.us = getelementptr inbounds i16, ptr %data, i32 %add8.us
69 store i16 %add.us, ptr %arrayidx9.us, align 2
70 %inc.us = add nuw nsw i32 %j.053.us, 1
71 %exitcond = icmp eq i32 %inc.us, %n
72 br i1 %exitcond, label %for.body15.us, label %for.body4.us
74 for.body15.us: ; preds = %for.body4.us, %for.body15.us
75 %j10.055.us = phi i32 [ %inc26.us, %for.body15.us ], [ 0, %for.body4.us ]
76 %arrayidx16.us = getelementptr inbounds i16, ptr %off, i32 %j10.055.us
77 %l0 = load i16, ptr %arrayidx16.us, align 2
78 %arrayidx18.us = getelementptr inbounds i16, ptr %data, i32 %j10.055.us
79 %l1 = load i16, ptr %arrayidx18.us, align 2
80 %add20.us = add i16 %l1, %l0
81 %add23.us = add i32 %j10.055.us, %mul.us
82 %arrayidx24.us = getelementptr inbounds i16, ptr %dst, i32 %add23.us
83 store i16 %add20.us, ptr %arrayidx24.us, align 2
84 %inc26.us = add nuw nsw i32 %j10.055.us, 1
85 %exitcond93 = icmp eq i32 %inc26.us, %n
86 br i1 %exitcond93, label %for.cond.cleanup14.us, label %for.body15.us
88 for.cond.cleanup14.us: ; preds = %for.body15.us
89 %inc29.us = add nuw i32 %i.057.us, 1
90 %exitcond94 = icmp eq i32 %inc29.us, %n
91 br i1 %exitcond94, label %for.cond.cleanup, label %for.cond1.preheader.us
93 for.cond.cleanup: ; preds = %for.cond.cleanup14.us, %entry