[PATCH] D97406: [Vectorizers]Improve emission of logical or/and reductions.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 24 11:44:31 PST 2021


ABataev created this revision.
ABataev added reviewers: spatel, RKSimon, dtemirbulatov, anton-afanasyev.
Herald added a subscriber: hiraditya.
ABataev requested review of this revision.
Herald added a project: LLVM.

For logical or/and reductions we emit regular intrinsics @llvm.vector.reduce.or/and.vxi1 calls.
These intrinsics are not effective for the logical or/and reductions,
especially if the optimizer is able to emit short circuit versions of
the scalar or/and instructions and vector code gets less effective than
the scalar version.
Instead, or reduction for i1 can be represented as:

  %val = bitcast <ReduxWidth x i1> to iReduxWidth
  %res = cmp ne iReduxWidth %val, 0

and reduction for i1 can be represented as:

  %val = bitcast <ReduxWidth x i1> to iReduxWidth
  %res = cmp eq iReduxWidth %val, 11111

This improves perfromance of the vector code significantly and make it
to outperform short circuit scalar code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97406

Files:
  llvm/lib/Transforms/Utils/LoopUtils.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/test/Transforms/SLPVectorizer/X86/compare-reduce.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97406.326167.patch
Type: text/x-patch
Size: 8703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210224/1d792cdc/attachment.bin>


More information about the llvm-commits mailing list