[PATCH] D143193: [DAG] Add visitABD optimizations

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 2 08:34:15 PST 2023


dmgreen created this revision.
dmgreen added reviewers: RKSimon, spatel, jaykang10.
Herald added subscribers: StephenFan, ecnelises, hiraditya.
Herald added a project: All.
dmgreen requested review of this revision.
Herald added a project: LLVM.

This adds basic a visitABD to optimize ABDS and ABDU nodes, similar to the existing visitAVG method.

The fold I was initially interested in was folding shuffles though the binop. This also:

- Marks ABDS and ABDU as commutative binops (https://alive2.llvm.org/ce/z/oCDogb and https://alive2.llvm.org/ce/z/7zrs86).
- Add constant folding using `max(x,y)-min(x,y)`
- Canonicalizes constants to the RHS
- Folds `abds x, 0 -> abs(x)` (https://alive2.llvm.org/ce/z/4ZEibv)
- Folds `abdu x, 0 -> x` (https://alive2.llvm.org/ce/z/J_rKqx)
- Folds `abd x, undef -> 0` (https://alive2.llvm.org/ce/z/NV6Nsv and https://alive2.llvm.org/ce/z/vs92hu).


https://reviews.llvm.org/D143193

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/test/CodeGen/AArch64/abd-combine.ll
  llvm/test/CodeGen/AArch64/arm64-neon-aba-abd.ll
  llvm/test/CodeGen/Thumb2/mve-vabdus.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143193.494321.patch
Type: text/x-patch
Size: 13484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230202/ed79b56e/attachment.bin>


More information about the llvm-commits mailing list