[PATCH] D87936: [GISel] Add new combines for G_ADD
Michael Kitzan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 19 10:50:48 PDT 2022
mkitzan added inline comments.
================
Comment at: llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h:739
+ /// Transform G_ADD(x, -cst) to G_SUB(x, cst).
+ bool matchAddNegConstant(MachineInstr &MI, APInt &Cst);
----------------
foad wrote:
> Does SelectionDAG do this? I suppose it can be useful to canonicalize, but my gut feeling is that it would be better to do the converse, i.e. canonicalize G_SUB(x, cst) -> G_ADD(x, -cst). That way you are canonicalizing on using G_ADD instead of G_SUB wherever possible, which feels more useful than using positive constants instead of negative constants wherever possible. E.g. if you're writing a pattern to match a "reg + simm" addressing mode you would only need to match G_ADD.
No, I can't seem to find it in DAGCombiner. Would you rather it be removed from the patch?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87936/new/
https://reviews.llvm.org/D87936
More information about the llvm-commits
mailing list