[PATCH] D129626: [AArch64] Add patterns to fold zext(cmpeq(x, splat(0)))
Paul Walker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 15 07:20:49 PDT 2022
paulwalker-arm added inline comments.
================
Comment at: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td:451
+ // zext(cmpeq(x, splat(0))) -> cnot(x)
+ def : Pat<(nxv16i8 (zext (nxv16i1 (AArch64setcc_z (nxv16i1 (AArch64ptrue 31)), nxv16i8:$Op2, (SVEDup0), SETEQ)))),
+ (CNOT_ZPmZ_B $Op2, (PTRUE_B 31), $Op2)>;
----------------
Here you should be able to use `(SVEAllActive):$Pg` that will catch more cases whilst also enabling you to use `$Pg` in place of `(PTRUE_# 31)`.
================
Comment at: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td:451-452
+ // zext(cmpeq(x, splat(0))) -> cnot(x)
+ def : Pat<(nxv16i8 (zext (nxv16i1 (AArch64setcc_z nxv16i1:$Op1, nxv16i8:$Op2, (SVEDup0), SETEQ)))),
+ (CNOT_ZPmZ_B $Op2, $Op1, $Op2)>;
+ def : Pat<(nxv8i16 (zext (nxv8i1 (AArch64setcc_z nxv8i1:$Op1, nxv8i16:$Op2, (SVEDup0), SETEQ)))),
----------------
c-rhodes wrote:
> paulwalker-arm wrote:
> > Are you sure these produce the same result? It looks like the input pattern sets the result of inactive lanes to zero but `CNOT_ZPmZ_B` will set them to whatever is in `$Op2`. Perhaps the pattern should be restricted to all active predicates.
> >
> > Is it possible to add these patterns to the PatFrags used to define `AArch64cnot_mt`?
> > Are you sure these produce the same result? It looks like the input pattern sets the result of inactive lanes to zero but `CNOT_ZPmZ_B` will set them to whatever is in `$Op2`. Perhaps the pattern should be restricted to all active predicates.
>
> Good spot! I've updated the patterns to only match all active predicate.
>
> > Is it possible to add these patterns to the PatFrags used to define `AArch64cnot_mt`?
>
> I can't figure out how to express the all active predicate restriction in a PatFrag, happy to make the change if you know how.
>
Fair enough. With the all active restriction they're not really the same thing anymore so my PatFrag idea goes out of the window.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129626/new/
https://reviews.llvm.org/D129626
More information about the llvm-commits
mailing list