[PATCH] D134703: [RISCV][ISel] Refactor the formation of VW operations

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 26 21:58:56 PDT 2022


qcolombet created this revision.
qcolombet added reviewers: craig.topper, reames.
Herald added subscribers: sunshaoce, VincentWu, StephenFan, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
qcolombet requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

This patch centralizes all the combines of `add|sub|mul` with extended operands in one "framework".
The rationale for this change is to offer a one-stop-shop for all these transformations so that, in the future (next patch), it is easier to make combine decisions for a web of instructions (i.e., instructions connected through s|zext operands).

Technically this patch is not NFC because the new version is more powerful than the previous version.
In particular, it diverges in two cases:

- VWMULSU can now also be produced from `mul(splat, zext)`, whereas previously only `mul(sext, splat)` were supported when `splat`s were involved. (As demonstrated in `rvv/fixed-vectors-vwmulsu.ll`)
- VWSUB(U) can now also be produced from `sub(splat, ext)`, whereas previously only `sub(ext, splat)` were supported when `splat`s were involved. (As demonstrated in `rvv/fixed-vectors-vwsub.ll`)

If we wanted, we could block these transformations to make this patch really NFC. For instance, we could do something similar to `AllowSplatInVW_W`, which prevents the combines to form `vw(add|sub)(u)_w` when the RHS is a splat.

Regarding the "framework" itself, the bulk of the patch is some boilderplate code that abstracts away the actual extensions that are present in the DAG. This allows us to handle `vwadd_w(ext a, b)` as if it was a regular `add(ext a, ext b)`. Since the node `ext b` doesn't actually exist in the DAG, we have a bunch of methods (all in the `NodeExtensionHelper` class) that fake all that for us.

The other half of the change is around `CombineToTry` and `CombineResult`. These helper structures respectively:

- Represent the kind of combines that can be applied to a node, and
- Store what needs to happen to do that combine.

This can be viewed as a two step approach:

- First, check if a pattern applies, and
- Second apply it.

The checks and the materialization of the combines are decoupled so that in the future we can perform several checks and do all the related applies in one go.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134703

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vwmul.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vwmulsu.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vwsub.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vwsubu.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134703.463091.patch
Type: text/x-patch
Size: 41280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220927/f55ace09/attachment.bin>


More information about the llvm-commits mailing list