xref: /llvm-project/llvm/test/Transforms/LoopVectorize/RISCV/force-vect-msg.ll (revision c836b8956d393f98e0d4e136799a33f1bd06e5f5)
1; REQUIRES: asserts
2; RUN: opt < %s -passes=loop-vectorize -mtriple riscv64 -riscv-v-vector-bits-min=128 -mattr="+v" -debug-only=loop-vectorize --disable-output -S 2>&1 | FileCheck %s
3
4; CHECK: LV: Loop hints: force=enabled
5; CHECK: LV: Scalar loop costs: 4.
6; ChosenFactor.Cost is 4, but the real cost will be divided by the width, which is 2.
7; CHECK: Cost for VF 2: 4 (Estimated cost per lane: 2.0)
8; Regardless of force vectorization or not, this loop will eventually be vectorized because of the cost model.
9; Therefore, the following message does not need to be printed even if vectorization is explicitly forced in the metadata.
10; CHECK-NOT: LV: Vectorization seems to be not beneficial, but was forced by a user.
11
12target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
13target triple = "riscv64-unknown-unknown"
14
15define i64 @foo(ptr nocapture noundef readonly %a, i64 noundef %N, i64 noundef %init) {
16entry:
17  br label %for.body
18
19for.body:                                         ; preds = %entry, %for.body
20  %i.06 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
21  %rd.05 = phi i64 [ %add, %for.body ], [ %init, %entry ]
22  %arrayidx = getelementptr inbounds i64, ptr %a, i64 %i.06
23  %0 = load i64, ptr %arrayidx, align 8
24  %add = add nsw i64 %0, %rd.05
25  %inc = add nuw i64 %i.06, 1
26  %exitcond.not = icmp eq i64 %inc, %N
27  br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !0
28
29for.end:                                          ; preds = %for.body
30  ret i64 %add
31}
32
33!0 = !{!0, !1}
34!1 = !{!"llvm.loop.vectorize.enable", i1 true}
35