1 ; RUN: opt -S < %s -passes=loop-vectorize -mtriple aarch64-linux-gnu -mattr=+sve 2>&1 | FileCheck %s
3 define void @clamped_tc_8(ptr nocapture %dst, i32 %n, i64 %val){
4 ; CHECK-LABEL: define void @clamped_tc_8
5 ; CHECK: call void @llvm.masked.store.nxv8i8.p0(<vscale x 8 x i8> {{.*}}, ptr {{.*}}, i32 1, <vscale x 8 x i1> {{.*}})
9 for.body: ; preds = %entry, %for.body
10 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
11 %p_out_tail.09 = phi ptr [ %dst, %entry ], [ %incdec.ptr, %for.body ]
12 %0 = shl nuw nsw i64 %indvars.iv, 3
13 %shr3 = lshr i64 %val, %0
14 %conv4 = trunc i64 %shr3 to i8
15 store i8 %conv4, ptr %p_out_tail.09, align 1
16 %incdec.ptr = getelementptr inbounds i8, ptr %p_out_tail.09, i64 1
17 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
18 %exitcond.not = icmp eq i64 %indvars.iv.next, 8
19 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
21 for.cond.cleanup: ; preds = %for.body
25 define void @clamped_tc_max_8(ptr nocapture %dst, i32 %n, i64 %val){
26 ; CHECK-LABEL: define void @clamped_tc_max_8(
27 ; CHECK: call void @llvm.masked.store.nxv8i8.p0(<vscale x 8 x i8> {{.*}}, ptr {{.*}}, i32 1, <vscale x 8 x i1> {{.*}})
31 %cmp8.not = icmp eq i32 %rem, 0
32 br i1 %cmp8.not, label %for.cond.cleanup, label %for.body.preheader
34 for.body.preheader: ; preds = %entry
35 %add = add nuw nsw i32 %rem, 7
36 %shr = lshr i32 %add, 3
37 %wide.trip.count = zext i32 %shr to i64
40 for.body: ; preds = %for.body.preheader, %for.body
41 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
42 %p_out_tail.09 = phi ptr [ %dst, %for.body.preheader ], [ %incdec.ptr, %for.body ]
43 %0 = shl nuw nsw i64 %indvars.iv, 3
44 %shr3 = lshr i64 %val, %0
45 %conv4 = trunc i64 %shr3 to i8
46 store i8 %conv4, ptr %p_out_tail.09, align 1
47 %incdec.ptr = getelementptr inbounds i8, ptr %p_out_tail.09, i64 1
48 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
49 %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
50 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
52 for.cond.cleanup: ; preds = %for.body