1; RUN: opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-target-supports-scalable-vectors=true -S | FileCheck %s 2 3target 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" 4 5; CHECK-LABEL: @test1( 6; CHECK: store <8 x i32> 7; CHECK: ret void 8define void @test1(ptr nocapture %a, i32 %n) #0 { 9entry: 10 %cmp4 = icmp sgt i32 %n, 0 11 br i1 %cmp4, label %for.body, label %for.end 12 13for.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 21 22for.end: ; preds = %for.body, %entry 23 ret void 24} 25 26; CHECK-LABEL: @test2( 27; CHECK: store <vscale x 8 x i32> 28; CHECK: ret void 29define void @test2(ptr nocapture %a, i32 %n) #0 { 30entry: 31 %cmp4 = icmp sgt i32 %n, 0 32 br i1 %cmp4, label %for.body, label %for.end 33 34for.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 42 43for.end: ; preds = %for.body, %entry 44 ret void 45} 46 47; CHECK-LABEL: @test3( 48; CHECK: store <8 x i32> 49; CHECK: ret void 50define void @test3(ptr nocapture %a, i32 %n) #0 { 51entry: 52 %cmp4 = icmp sgt i32 %n, 0 53 br i1 %cmp4, label %for.body, label %for.end 54 55for.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 63 64for.end: ; preds = %for.body, %entry 65 ret void 66} 67 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'. 70 71; CHECK-LABEL: @test4( 72; CHECK: store <8 x i32> 73; CHECK: ret void 74define void @test4(ptr nocapture %a, i32 %n) #0 { 75entry: 76 %cmp4 = icmp sgt i32 %n, 0 77 br i1 %cmp4, label %for.body, label %for.end 78 79for.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 87 88for.end: ; preds = %for.body, %entry 89 ret void 90} 91 92attributes #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" } 93 94!0 = !{!0, !1, !5} 95!1 = !{!"llvm.loop.vectorize.width", i32 8} 96!2 = !{!2, !1, !3} 97!3 = !{!"llvm.loop.vectorize.scalable.enable", i32 1} 98!4 = !{!4, !1, !5} 99!5 = !{!"llvm.loop.vectorize.scalable.enable", i32 0} 100!6 = !{!6, !7} 101!7 = !{!"llvm.loop.vectorize.width", i32 8} 102