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