[PATCH] D73480: [VectorCombine] new IR transform pass for partial vector ops

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 07:53:22 PST 2020


spatel created this revision.
spatel added reviewers: nemanjai, craig.topper, hfinkel, efriedma, lebedev.ri, RKSimon.
Herald added subscribers: dexonsmith, steven_wu, hiraditya, mgorny, mcrosier, mehdi_amini.
Herald added a project: LLVM.

We have several bug reports that could be characterized as "reducing scalarization", and this topic was also raised on llvm-dev recently:
http://lists.llvm.org/pipermail/llvm-dev/2020-January/138157.html
...so I'm proposing that we deal with these patterns in a new, lightweight IR vector pass that runs before/after other vectorization passes.

There are 4 alternate options that I can think of to deal with this kind of problem (and we've seen various attempts at all of these), but they all have flaws:

1. InstCombine - can't happen without TTI, but we don't want target-specific folds there.
2. SDAG - too late to assist other vectorization passes; TLI is not equipped for these kind of cost queries; limited to a single basic block.
3. CGP - too late to assist other vectorization passes; would need to re-implement basic cleanups like CSE/instcombine.
4. SLP - doesn't fit with existing transforms; limited to a single basic block.

This initial patch/transform is based on existing code in AggressiveInstCombine: we walk backwards through the function looking for a pattern match. But we diverge from that cost-independent IR canonicalization pass by using TTI to decide if the vector alternative is profitable.

We probably have at least 10 similar bug reports/patterns (binops, constants, inserts, cheap shuffles, etc) that would fit in this pass as follow-up enhancements. It's possible that we could iterate on a worklist to fix-point like InstCombine does, but it's safer to start with a most basic case and evolve from there, so I didn't try to do anything fancy here.


https://reviews.llvm.org/D73480

Files:
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Transforms/Vectorize.h
  llvm/include/llvm/Transforms/Vectorize/VectorCombine.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Vectorize/CMakeLists.txt
  llvm/lib/Transforms/Vectorize/VectorCombine.cpp
  llvm/lib/Transforms/Vectorize/Vectorize.cpp
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/Transforms/VectorCombine/X86/extract-cmp.ll
  llvm/test/Transforms/VectorCombine/X86/lit.local.cfg

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73480.240569.patch
Type: text/x-patch
Size: 25280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200127/d484636d/attachment.bin>


More information about the llvm-commits mailing list