[PATCH] D128523: [LV][NFC] Fix the condition for printing debug messages

Mel Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 15 01:35:04 PDT 2022


Mel-Chen updated this revision to Diff 444912.
Mel-Chen added a comment.

Update test case according to the comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128523/new/

https://reviews.llvm.org/D128523

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/RISCV/force-vect-msg.ll


Index: llvm/test/Transforms/LoopVectorize/RISCV/force-vect-msg.ll
===================================================================
--- llvm/test/Transforms/LoopVectorize/RISCV/force-vect-msg.ll
+++ llvm/test/Transforms/LoopVectorize/RISCV/force-vect-msg.ll
@@ -3,8 +3,11 @@
 
 ; CHECK: LV: Loop hints: force=enabled
 ; CHECK: LV: Scalar loop costs: 7.
+; ChosenFactor.Cost is 8, but the real cost will be divided by the width, which is 4.
 ; CHECK: LV: Vector loop of width 2 costs: 4.
-; CHECK: LV: Vectorization seems to be not beneficial, but was forced by a user.
+; Regardless of force vectorization or not, this loop will eventually be vectorized because of the cost model.
+; Therefore, the following message does not need to be printed even if vectorization is explicitly forced in the metadata.
+; CHECK-NOT: LV: Vectorization seems to be not beneficial, but was forced by a user.
 
 target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
 target triple = "riscv64-unknown-unknown"
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5406,7 +5406,7 @@
   }
 
   LLVM_DEBUG(if (ForceVectorization && !ChosenFactor.Width.isScalar() &&
-                 ChosenFactor.Cost >= ScalarCost.Cost) dbgs()
+                 !isMoreProfitable(ChosenFactor, ScalarCost)) dbgs()
              << "LV: Vectorization seems to be not beneficial, "
              << "but was forced by a user.\n");
   LLVM_DEBUG(dbgs() << "LV: Selecting VF: " << ChosenFactor.Width << ".\n");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128523.444912.patch
Type: text/x-patch
Size: 1656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220715/8faa7fff/attachment.bin>


More information about the llvm-commits mailing list