[PATCH] D154157: [LV] Cost model for out-of-loop reductions

Anna Thomas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 14:47:54 PDT 2023


anna created this revision.
anna added reviewers: fhahn, dmgreen, ebrevnov.
Herald added subscribers: artagnon, StephenFan, pengfei, hiraditya.
Herald added a project: All.
anna requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When we have small trip count loops, the cost of out of loop reduction
becomes significant. We do not consider the cost of out of loop
reductions in loop vectorizer (in-loop vectorizations are handled in
cost modelling).

This patch introduces a TTI hook to consider if we should vectorize
small trip counts when we have reductions being vectorized.

Added an X86 test which shows the patch avoids vectorizing the loop.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154157

Files:
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/X86/X86TargetTransformInfo.cpp
  llvm/lib/Target/X86/X86TargetTransformInfo.h
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/X86/reduction-small-trip-count.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154157.536010.patch
Type: text/x-patch
Size: 7509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230629/e0b8b699/attachment.bin>


More information about the llvm-commits mailing list