Skip to content

Commit 7508a6d

Browse files
committed
Precommit test case.
1 parent 3ad2399 commit 7508a6d

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 intstruction are same as
7+
; their scalar instruction.
8+
9+
; DEBUGLOC-LABEL: define void @vp_select(
10+
define void @vp_select(ptr noalias %a, ptr noalias %b, ptr noalias %c, i64 %N) {
11+
; DEBUGLOC: vector.body:
12+
; DEBUGLOC: %[[VPSel:[0-9]+]] = call <vscale x 4 x i32> @llvm.vp.select.nxv4i32(<vscale x 4 x i1> %15, <vscale x 4 x i32> %vp.op.load1, <vscale x 4 x i32> %vp.op, i32 %9)
13+
; DEBUGLOC: for.body:
14+
; DEBUGLOC: %cond.p = select i1 %cmp4, i32 %22, i32 %23, !dbg !39
15+
entry:
16+
br label %for.body
17+
18+
for.body:
19+
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
20+
%arrayidx = getelementptr inbounds i32, ptr %b, i64 %indvars.iv
21+
%0 = load i32, ptr %arrayidx, align 4
22+
%arrayidx3 = getelementptr inbounds i32, ptr %c, i64 %indvars.iv
23+
%1 = load i32, ptr %arrayidx3, align 4
24+
%cmp4 = icmp sgt i32 %0, %1
25+
%2 = sub i32 0, %1
26+
%cond.p = select i1 %cmp4, i32 %1, i32 %2
27+
%cond = add i32 %cond.p, %0
28+
%arrayidx15 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
29+
store i32 %cond, ptr %arrayidx15, align 4
30+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
31+
%exitcond.not = icmp eq i64 %indvars.iv.next, %N
32+
br i1 %exitcond.not, label %exit, label %for.body
33+
34+
exit:
35+
ret void
36+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
; RUN: opt < %s -passes=debugify,loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -prefer-inloop-reductions -S | FileCheck %s -check-prefix DEBUGLOC
2+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3+
4+
; Testing the debug locations of the generated vector intstruction are same as
5+
; their scalar instruction.
6+
7+
; DEBUGLOC-LABEL: define i32 @reduction_sum(
8+
define i32 @reduction_sum(ptr noalias nocapture %A, ptr noalias nocapture %B) {
9+
; DEBUGLOC: vector.body:
10+
; DEBUGLOC: %[[VecLoad:.*]] = load <4 x i32>, ptr %2, align 4, !dbg ![[LoadLoc0:[0-9]+]]
11+
; DEBUGLOC: %[[VecRed:.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %wide.load), !dbg ![[LoadLoc0]]
12+
; DEBUGLOC: .lr.ph:
13+
; DEBUGLOC: %l3 = load i32, ptr %l2, align 4, !dbg ![[LoadLoc0]]
14+
; DEBUGLOC: %l7 = add i32 %sum.02, %l3, !dbg ![[RedLoc0:[0-9]+]]
15+
entry:
16+
br label %.lr.ph
17+
18+
.lr.ph: ; preds = %entry, %.lr.ph
19+
%indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %entry ]
20+
%sum.02 = phi i32 [ %l7, %.lr.ph ], [ 0, %entry ]
21+
%l2 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
22+
%l3 = load i32, ptr %l2, align 4
23+
%l6 = trunc i64 %indvars.iv to i32
24+
%l7 = add i32 %sum.02, %l3
25+
%indvars.iv.next = add i64 %indvars.iv, 1
26+
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
27+
%exitcond = icmp eq i32 %lftr.wideiv, 256
28+
br i1 %exitcond, label %._crit_edge, label %.lr.ph
29+
30+
._crit_edge: ; preds = %.lr.ph
31+
%sum.0.lcssa = phi i32 [ %l7, %.lr.ph ]
32+
ret i32 %sum.0.lcssa
33+
}

0 commit comments

Comments
 (0)