2 ; RUN: opt --passes=loop-vectorize --mtriple loongarch64-linux-gnu \
3 ; RUN: --mattr=+lsx -debug-only=loop-vectorize --force-vector-width=1 \
4 ; RUN: -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK-SCALAR
5 ; RUN: opt --passes=loop-vectorize --mtriple loongarch64-linux-gnu \
6 ; RUN: --mattr=+lsx -debug-only=loop-vectorize --force-vector-width=4 \
7 ; RUN: -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK-VECTOR
9 define void @bar(ptr %A, i32 signext %n) {
11 ; CHECK-SCALAR: LV(REG): Found max usage: 2 item
12 ; CHECK-SCALAR-NEXT: LV(REG): RegisterClass: LoongArch::GPRRC, 2 registers
13 ; CHECK-SCALAR-NEXT: LV(REG): RegisterClass: LoongArch::FPRRC, 1 registers
14 ; CHECK-SCALAR-NEXT: LV(REG): Found invariant usage: 1 item
15 ; CHECK-SCALAR-NEXT: LV(REG): RegisterClass: LoongArch::GPRRC, 1 registers
16 ; CHECK-SCALAR-NEXT: LV: The target has 30 registers of LoongArch::GPRRC register class
17 ; CHECK-SCALAR-NEXT: LV: The target has 32 registers of LoongArch::FPRRC register class
18 ; CHECK-VECTOR: LV(REG): Found max usage: 1 item
19 ; CHECK-VECTOR-NEXT: LV(REG): RegisterClass: LoongArch::VRRC, 3 registers
20 ; CHECK-VECTOR-NEXT: LV(REG): Found invariant usage: 1 item
21 ; CHECK-VECTOR-NEXT: LV(REG): RegisterClass: LoongArch::GPRRC, 1 registers
22 ; CHECK-VECTOR-NEXT: LV: The target has 32 registers of LoongArch::VRRC register class
25 %cmp4 = icmp sgt i32 %n, 0
26 br i1 %cmp4, label %for.body.preheader, label %for.cond.cleanup
28 for.body.preheader: ; preds = %entry
29 %wide.trip.count = zext nneg i32 %n to i64
32 for.cond.cleanup: ; preds = %for.body, %entry
35 for.body: ; preds = %for.body.preheader, %for.body
36 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
37 %0 = trunc i64 %indvars.iv to i32
38 %conv = sitofp i32 %0 to float
39 %arrayidx = getelementptr inbounds float, ptr %A, i64 %indvars.iv
40 store float %conv, ptr %arrayidx, align 4
41 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
42 %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
43 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body