[PATCH] D79971: [X86] Rewrite how X86PartialReduction find candidates to consider optimizing.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 14 15:15:15 PDT 2020


craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Previously we walked the users of any vector binop looking for
more binops with the same opcode or phis that eventually ended up
in a reduction. While this is simple it also means visiting the
same nodes many times since we'll do a forward walk for each
BinaryOperator in the chain. It was also far more general than what
we have tests for or expect to see.

This patch replaces the algorithm with a new method that starts at
extract elements looking for a horizontal reduction. Once we find
a reduction we walk through backwards through phis and adds to
collect leaves that we can consider for rewriting.

We only consider single use adds and phis. Except for a special
case if the Add is used by a phi that forms a loop back to the
Add. Including other single use Adds to support unrolled loops.

Ultimately, I want to narrow the Adds, Phis, and final reduction
based on the partial reduction we're doing. I still haven't
figured out exactly what that looks like yet. But restricting
the types of graphs we expect to handle seemed like a good first
step. As does having all the leaves and the reduction at once.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79971

Files:
  llvm/lib/Target/X86/X86PartialReduction.cpp
  llvm/test/CodeGen/X86/madd.ll
  llvm/test/CodeGen/X86/sad.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79971.264111.patch
Type: text/x-patch
Size: 17846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200514/ea4bddb6/attachment.bin>


More information about the llvm-commits mailing list