This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Add patterns to fold zext(cmpeq(x, splat(0)))
ClosedPublic

Authored by c-rhodes on Jul 13 2022, 2:44 AM.

Diff Detail

Event Timeline

c-rhodes created this revision.Jul 13 2022, 2:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2022, 2:44 AM
c-rhodes requested review of this revision.Jul 13 2022, 2:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2022, 2:44 AM
c-rhodes updated this revision to Diff 444230.Jul 13 2022, 5:12 AM

Add patterns for all legal FP types.

c-rhodes updated this revision to Diff 444258.Jul 13 2022, 7:41 AM

Remove FP patterns.

paulwalker-arm added inline comments.Jul 13 2022, 4:26 PM
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
451–452

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?

c-rhodes updated this revision to Diff 444584.Jul 14 2022, 3:58 AM

Restrict patterns to all active predicate.

c-rhodes added inline comments.Jul 14 2022, 4:00 AM
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
451–452

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.

Matt added a subscriber: Matt.Jul 14 2022, 10:48 AM
paulwalker-arm added inline comments.Jul 15 2022, 7:20 AM
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
451–452

Fair enough. With the all active restriction they're not really the same thing anymore so my PatFrag idea goes out of the window.

459

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).

c-rhodes updated this revision to Diff 444979.Jul 15 2022, 7:35 AM

Use SVEAllActive

c-rhodes marked an inline comment as done.Jul 15 2022, 7:36 AM
paulwalker-arm accepted this revision.Jul 15 2022, 8:52 AM
This revision is now accepted and ready to land.Jul 15 2022, 8:52 AM
This revision was landed with ongoing or failed builds.Jul 19 2022, 1:15 AM
This revision was automatically updated to reflect the committed changes.