This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] More consistently use buildvector for zero and all-ones constants
ClosedPublic

Authored by dmgreen on Feb 14 2023, 8:11 AM.

Details

Summary

The AArch64 backend will use legal BUILDVECTORs for zero vectors or all-ones vectors, so during selection tablegen patterns get rely on immAllZerosV and immAllOnesV pattern frags in patters like vnot. It was not always consistent though, which this patch attempt to fix by recognizing where constant splat + insert vector element is used. The main outcome of this will be that full vector movi v0.2d, #0000000000000000 will be used as opposed to movi d0, #0, as per https://reviews.llvm.org/D53579. This helps simplify what tablegen will see, to make pattern matching simpler.

Diff Detail

Event Timeline

dmgreen created this revision.Feb 14 2023, 8:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 14 2023, 8:11 AM
dmgreen requested review of this revision.Feb 14 2023, 8:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 14 2023, 8:11 AM
dmgreen edited the summary of this revision. (Show Details)Feb 14 2023, 8:19 AM

Looks sensible to me! I just had one minor comment ...

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
12445

Instead of asking this question for the build vector Vec can you just instead test ConstantValue for 0 or 1 instead, since it's probably cheaper?

dmgreen updated this revision to Diff 498059.Feb 16 2023, 10:04 AM
dmgreen added inline comments.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
12445

Zero's are simple, but all-ones are a little more complex due to promotion of the constants to 32bits.

david-arm accepted this revision.Feb 20 2023, 3:48 AM

LGTM! Thanks for making the changes @dmgreen. :)

This revision is now accepted and ready to land.Feb 20 2023, 3:48 AM
This revision was landed with ongoing or failed builds.Feb 20 2023, 6:13 AM
This revision was automatically updated to reflect the committed changes.