xref: /llvm-project/llvm/test/Transforms/LoopVectorize/RISCV/preserve-dbg-loc.ll (revision 47e1c87a613d7453b6d5addc2e23e26bea10c0ce)
1; RUN: opt -passes=debugify,loop-vectorize \
2; RUN: -force-tail-folding-style=data-with-evl \
3; RUN: -prefer-predicate-over-epilogue=predicate-dont-vectorize \
4; RUN: -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 -S < %s 2>&1 | FileCheck --check-prefix=DEBUGLOC %s
5
6; Testing the debug locations of the generated vector intrinsic is same as
7; its scalar counterpart.
8
9define void @vp_select(ptr %a, ptr %b, ptr %c, i64 %N) {
10; DEBUGLOC-LABEL: define void @vp_select(
11; DEBUGLOC: vector.body:
12; DEBUGLOC:   = call <vscale x 4 x i32> @llvm.vp.select.nxv4i32(<vscale x 4 x i1> %{{.+}}, <vscale x 4 x i32> %{{.+}}, <vscale x 4 x i32> %{{.+}}, i32 %{{.+}}), !dbg ![[SELLOC:[0-9]+]]
13; DEBUGLOC: loop:
14; DEBUGLOC:   = select i1 %{{.+}}, i32 %{{.+}}, i32 %{{.+}}, !dbg ![[SELLOC]]
15;
16 entry:
17   br label %loop
18
19loop:
20   %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
21   %gep.b = getelementptr inbounds i32, ptr %b, i64 %iv
22   %load.b = load i32, ptr %gep.b, align 4
23   %gep.c = getelementptr inbounds i32, ptr %c, i64 %iv
24   %load.c = load i32, ptr %gep.c, align 4
25   %cmp = icmp sgt i32 %load.b, %load.c
26   %neg.c = sub i32 0, %load.c
27   %sel = select i1 %cmp, i32 %load.c, i32 %neg.c
28   %add = add i32 %sel, %load.b
29   %gep.a = getelementptr inbounds i32, ptr %a, i64 %iv
30   store i32 %add, ptr %gep.a, align 4
31   %iv.next = add nuw nsw i64 %iv, 1
32   %exitcond = icmp eq i64 %iv.next, %N
33   br i1 %exitcond, label %exit, label %loop
34
35 exit:
36   ret void
37 }
38
39 ; DEBUGLOC: [[SELLOC]] = !DILocation(line: 9
40