brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · e535f8d Raw
81 lines · plain
1; RUN: opt < %s -passes=loop-vectorize,dce,instcombine,simplifycfg -force-vector-interleave=1 -force-vector-width=4 -S -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s2 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;6; We want to make sure that we are vectorizeing the scalar loop only once7; even if the pass manager runs the vectorizer multiple times due to inlining.8 9 10; This test checks that we add metadata to vectorized loops11; CHECK-LABEL: @_Z4foo1Pii(12; CHECK: <4 x i32>13; CHECK: br i1 %{{.*}}, label %{{.*}}, label %vector.body, !llvm.loop [[VEC_LOOP1:![0-9]+]]14;15; CHECK: br i1 %{{.*}}, label %{{.*}}, label %for.body.i, !llvm.loop [[SCALAR_LOOP1:![0-9]+]]16; CHECK: ret17 18; This test comes from the loop:19;20;int foo (int *A, int n) {21;  return std::accumulate(A, A + n, 0);22;}23define i32 @_Z4foo1Pii(ptr %A, i32 %n) #0 {24entry:25  %idx.ext = sext i32 %n to i6426  %add.ptr = getelementptr inbounds i32, ptr %A, i64 %idx.ext27  %cmp3.i = icmp eq i32 %n, 028  br i1 %cmp3.i, label %_ZSt10accumulateIPiiET0_T_S2_S1_.exit, label %for.body.i29 30for.body.i:                                       ; preds = %entry, %for.body.i31  %__init.addr.05.i = phi i32 [ %add.i, %for.body.i ], [ 0, %entry ]32  %__first.addr.04.i = phi ptr [ %incdec.ptr.i, %for.body.i ], [ %A, %entry ]33  %0 = load i32, ptr %__first.addr.04.i, align 434  %add.i = add nsw i32 %0, %__init.addr.05.i35  %incdec.ptr.i = getelementptr inbounds i32, ptr %__first.addr.04.i, i64 136  %cmp.i = icmp eq ptr %incdec.ptr.i, %add.ptr37  br i1 %cmp.i, label %_ZSt10accumulateIPiiET0_T_S2_S1_.exit, label %for.body.i38 39_ZSt10accumulateIPiiET0_T_S2_S1_.exit:            ; preds = %for.body.i, %entry40  %__init.addr.0.lcssa.i = phi i32 [ 0, %entry ], [ %add.i, %for.body.i ]41  ret i32 %__init.addr.0.lcssa.i42}43 44; This test checks that we don't vectorize loops that are marked with the "width" == 1 metadata.45; CHECK-LABEL: @_Z4foo2Pii(46; CHECK-NOT: <4 x i32>47; CHECK: br i1 %{{.*}}, label %{{.*}}, label %for.body.i, !llvm.loop [[SCALAR_LOOP2:![0-9]+]]48; CHECK: ret49define i32 @_Z4foo2Pii(ptr %A, i32 %n) #0 {50entry:51  %idx.ext = sext i32 %n to i6452  %add.ptr = getelementptr inbounds i32, ptr %A, i64 %idx.ext53  %cmp3.i = icmp eq i32 %n, 054  br i1 %cmp3.i, label %_ZSt10accumulateIPiiET0_T_S2_S1_.exit, label %for.body.i55 56for.body.i:                                       ; preds = %entry, %for.body.i57  %__init.addr.05.i = phi i32 [ %add.i, %for.body.i ], [ 0, %entry ]58  %__first.addr.04.i = phi ptr [ %incdec.ptr.i, %for.body.i ], [ %A, %entry ]59  %0 = load i32, ptr %__first.addr.04.i, align 460  %add.i = add nsw i32 %0, %__init.addr.05.i61  %incdec.ptr.i = getelementptr inbounds i32, ptr %__first.addr.04.i, i64 162  %cmp.i = icmp eq ptr %incdec.ptr.i, %add.ptr63  br i1 %cmp.i, label %_ZSt10accumulateIPiiET0_T_S2_S1_.exit, label %for.body.i, !llvm.loop !064 65_ZSt10accumulateIPiiET0_T_S2_S1_.exit:            ; preds = %for.body.i, %entry66  %__init.addr.0.lcssa.i = phi i32 [ 0, %entry ], [ %add.i, %for.body.i ]67  ret i32 %__init.addr.0.lcssa.i68}69 70attributes #0 = { nounwind readonly ssp uwtable "fp-contract-model"="standard" "frame-pointer"="non-leaf" "realign-stack" "relocation-model"="pic" "ssp-buffers-size"="8" }71 72; CHECK:      [[VEC_LOOP1]] = distinct !{[[VEC_LOOP1]], [[MD_IS_VEC:![0-9]+]], [[MD_RT_UNROLL_DIS:![0-9]+]]}73; CHECK-NEXT: [[MD_IS_VEC:![0-9]+]] = !{!"llvm.loop.isvectorized", i32 1}74; CHECK-NEXT: [[MD_RT_UNROLL_DIS]] = !{!"llvm.loop.unroll.runtime.disable"}75; CHECK-NEXT: [[SCALAR_LOOP1]] = distinct !{[[SCALAR_LOOP1]], [[MD_RT_UNROLL_DIS:![0-9]+]], [[MD_IS_VEC]]}76; CHECK-NEXT: [[SCALAR_LOOP2]] = distinct !{[[SCALAR_LOOP2]], [[VEC_WIDTH_1:![0-9]+]]}77; CHECK-NEXT: [[VEC_WIDTH_1]] = !{!"llvm.loop.vectorize.width", i32 1}78 79!0 = !{!0, !1}80!1 = !{!"llvm.loop.vectorize.width", i32 1}81