[DAG][AArch64][ARM] Combine abd(sub(x, y)) to abd if the sub is nsw
authorDavid Green <david.green@arm.com>
Wed, 18 Jan 2023 10:10:52 +0000 (10:10 +0000)
committerDavid Green <david.green@arm.com>
Wed, 18 Jan 2023 10:10:52 +0000 (10:10 +0000)
commite26ec330c4ff26c4f51e1bac4669b57c0edb5d3e
tree0af3402a3d87764bb7ffa84b22ba445f410d9a49
parent855beb1401cc823ab2f7f5c8c369dcc3da22634a
[DAG][AArch64][ARM] Combine abd(sub(x, y)) to abd if the sub is nsw

This implements the fold (abs (sub nsw x, y)) -> abds(x, y). Providing
the sub is nsw this appears to be valid without the extensions that are
usually used for abds. https://alive2.llvm.org/ce/z/XHVaB3. The
equivalent abdu combine seems to not be valid.

Differential Revision: https://reviews.llvm.org/D141665
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/neon-abd.ll