1 ; RUN: opt -hardware-loops -force-hardware-loops=true -hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 -S %s -o - | FileCheck %s
2 ; RUN: opt -hardware-loops -force-hardware-loops=true -hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 -force-hardware-loop-phi=true -S %s -o - | FileCheck %s
3 ; RUN: opt -hardware-loops -force-hardware-loops=true -hardware-loop-decrement=1 -hardware-loop-counter-bitwidth=32 -force-nested-hardware-loop=true -S %s -o - | FileCheck %s
5 ; CHECK-LABEL: float_counter
6 ; CHECK-NOT: set.loop.iterations
7 ; CHECK-NOT: loop.decrement
8 define void @float_counter(i32* nocapture %A, float %N) {
10 %cmp6 = fcmp ogt float %N, 0.000000e+00
11 br i1 %cmp6, label %while.body, label %while.end
14 %i.07 = phi i32 [ %inc, %while.body ], [ 0, %entry ]
15 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.07
16 store i32 %i.07, i32* %arrayidx, align 4
17 %inc = add i32 %i.07, 1
18 %conv = uitofp i32 %inc to float
19 %cmp = fcmp olt float %conv, %N
20 br i1 %cmp, label %while.body, label %while.end
26 ; CHECK-LABEL: variant_counter
27 ; CHECK-NOT: set.loop.iterations
28 ; CHECK-NOT: loop.decrement
29 define void @variant_counter(i32* nocapture %A, i32* nocapture readonly %B) {
31 %0 = load i32, i32* %B, align 4
32 %cmp7 = icmp eq i32 %0, 0
33 br i1 %cmp7, label %while.end, label %while.body
36 %i.08 = phi i32 [ %inc, %while.body ], [ 0, %entry ]
37 %arrayidx1 = getelementptr inbounds i32, i32* %A, i32 %i.08
38 store i32 %i.08, i32* %arrayidx1, align 4
39 %inc = add nuw i32 %i.08, 1
40 %arrayidx = getelementptr inbounds i32, i32* %B, i32 %inc
41 %1 = load i32, i32* %arrayidx, align 4
42 %cmp = icmp ult i32 %inc, %1
43 br i1 %cmp, label %while.body, label %while.end
49 ; CHECK-LABEL: variant_counter2
50 ; CHECK-NOT: set.loop.iterations
51 ; CHECK-NOT: loop.decrement
52 define void @variant_counter2(i8*, i8*, i64*) {
53 %4 = icmp eq i8* %0, %1
54 br i1 %4, label %9, label %5
57 %6 = getelementptr inbounds i64, i64* %2, i64 1
58 %7 = load i64, i64* %6, align 8
62 store i64 %14, i64* %6, align 8
69 %11 = phi i64 [ %7, %5 ], [ %14, %10 ]
70 %12 = phi i32 [ 0, %5 ], [ %15, %10 ]
71 %13 = phi i8* [ %0, %5 ], [ %16, %10 ]
72 %14 = shl nsw i64 %11, 4
73 %15 = add nuw nsw i32 %12, 1
74 %16 = getelementptr inbounds i8, i8* %13, i64 1
75 %17 = icmp ugt i32 %12, 14
76 %18 = icmp eq i8* %16, %1
78 br i1 %19, label %8, label %10