[PATCH] D157700: [GlobalIsSel] Allow using PatFrags with multiple defs as the root of a combine rule

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 03:42:44 PDT 2023


Pierre-vh marked an inline comment as done.
Pierre-vh added inline comments.


================
Comment at: llvm/include/llvm/Target/GlobalISel/Combine.td:163
 // Fold (fcanonicalize (fcanonicalize x)) -> (fcanonicalize x).
+def idempotent_prop_frags : GICombinePatFrag<
+  (outs root:$dst, $src), (ins),
----------------
foad wrote:
> This may be a silly question since I am not too familiar with PatFrags, and have no idea how they are implemented:
> 
> Why does a PatFrag like this have two defs, instead of one use and one def?
It's actually a design point I've been struggling with for a while, and the current iteration I've settled on (and that makes the most sense to me) is:
 - out operands are defined by some instruction in all alternatives of the PatFrag, they can only be machine operands
 - in operands are never defined by the patterns, they can be machine operands or immediates

Here the PatFrag defines `$src` so it's an out operand. If we wanted to also access `$x` that'd be an in operand because it's not defined by any instruction

Having `$srrc` as an out avoids having 2 defs that contradict each other, making the pattern impossible to match.

Another option could also be to always have a single def (the root) and just error when an inst is accidentally def'd twice with something like `error: impossible pattern` or something. Both have their pros and cons


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157700/new/

https://reviews.llvm.org/D157700



More information about the llvm-commits mailing list