1 ; RUN: opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-target-supports-scalable-vectors=true -S | FileCheck %s
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
6 ; CHECK: store <8 x i32>
8 define void @test1(ptr nocapture %a, i32 %n) #0 {
10 %cmp4 = icmp sgt i32 %n, 0
11 br i1 %cmp4, label %for.body, label %for.end
13 for.body: ; preds = %entry, %for.body
14 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
15 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
16 store i32 42, ptr %arrayidx, align 4
17 %indvars.iv.next = add i64 %indvars.iv, 1
18 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
19 %exitcond = icmp eq i32 %lftr.wideiv, %n
20 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0
22 for.end: ; preds = %for.body, %entry
26 ; CHECK-LABEL: @test2(
27 ; CHECK: store <vscale x 8 x i32>
29 define void @test2(ptr nocapture %a, i32 %n) #0 {
31 %cmp4 = icmp sgt i32 %n, 0
32 br i1 %cmp4, label %for.body, label %for.end
34 for.body: ; preds = %entry, %for.body
35 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
36 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
37 store i32 42, ptr %arrayidx, align 4
38 %indvars.iv.next = add i64 %indvars.iv, 1
39 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
40 %exitcond = icmp eq i32 %lftr.wideiv, %n
41 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !2
43 for.end: ; preds = %for.body, %entry
47 ; CHECK-LABEL: @test3(
48 ; CHECK: store <8 x i32>
50 define void @test3(ptr nocapture %a, i32 %n) #0 {
52 %cmp4 = icmp sgt i32 %n, 0
53 br i1 %cmp4, label %for.body, label %for.end
55 for.body: ; preds = %entry, %for.body
56 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
57 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
58 store i32 42, ptr %arrayidx, align 4
59 %indvars.iv.next = add i64 %indvars.iv, 1
60 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
61 %exitcond = icmp eq i32 %lftr.wideiv, %n
62 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !4
64 for.end: ; preds = %for.body, %entry
68 ; Test that when only the width property is specified, and not the scalable.enable flag,
69 ; that the hint defaults to 'scalable.enable = false'.
71 ; CHECK-LABEL: @test4(
72 ; CHECK: store <8 x i32>
74 define void @test4(ptr nocapture %a, i32 %n) #0 {
76 %cmp4 = icmp sgt i32 %n, 0
77 br i1 %cmp4, label %for.body, label %for.end
79 for.body: ; preds = %entry, %for.body
80 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
81 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
82 store i32 42, ptr %arrayidx, align 4
83 %indvars.iv.next = add i64 %indvars.iv, 1
84 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
85 %exitcond = icmp eq i32 %lftr.wideiv, %n
86 br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !6
88 for.end: ; preds = %for.body, %entry
92 attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
95 !1 = !{!"llvm.loop.vectorize.width", i32 8}
97 !3 = !{!"llvm.loop.vectorize.scalable.enable", i32 1}
99 !5 = !{!"llvm.loop.vectorize.scalable.enable", i32 0}
101 !7 = !{!"llvm.loop.vectorize.width", i32 8}