This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] Legalize scalar G_CTTZ + G_CTTZ_ZERO_UNDEF
ClosedPublic

Authored by paquette on Jun 10 2021, 2:51 PM.

Details

Summary

This adds legalization for scalar G_CTTZ and G_CTTZ_ZERO_UNDEF. Vector support requires handling vector G_BITREVERSE, which I haven't gotten around to yet.

For G_CTTZ_ZERO_UNDEF, we just lower it to G_CTTZ.

For G_CTTZ, we match SelectionDAG's lowering to a G_BITREVERSE + G_CTLZ.

e.g. https://godbolt.org/z/nPEseYh1s

(With this patch, we have slightly worse codegen than SDAG for types smaller than s32; it seems like we're missing a combine.)

Also, this adds in a function to build G_BITREVERSE to MachineIRBuilder.

Diff Detail

Event Timeline

paquette created this revision.Jun 10 2021, 2:51 PM
paquette requested review of this revision.Jun 10 2021, 2:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2021, 2:51 PM
This revision is now accepted and ready to land.Jun 10 2021, 3:04 PM
This revision was landed with ongoing or failed builds.Jun 10 2021, 3:30 PM
This revision was automatically updated to reflect the committed changes.