This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GISel] Legalize non-power-of-two G_CTTZ
ClosedPublic

Authored by lenary on Apr 5 2023, 4:39 AM.

Details

Summary

The main change here is to add a widenScalarToNextPow2 before the
clampScalar so that non-power-of-two sizes between 32 and 64 are
turned into s64 count trailing zeroes.

However, if you make the legalisation rules depend on TypeIdx 0 (the
output), then you still get crashes for the s65 testcase, which I solved
by instead flipping the rules around to be about TypeIdx 1 (the input),
with a scalarSameSizeAs at the end to tie index 0 to index 1. This,
incidentally, is how things are written for G_CTLZ.

Diff Detail

Event Timeline

lenary created this revision.Apr 5 2023, 4:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2023, 4:39 AM
lenary requested review of this revision.Apr 5 2023, 4:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2023, 4:39 AM
lenary updated this revision to Diff 512871.Apr 12 2023, 9:23 AM
lenary edited the summary of this revision. (Show Details)
stuij added a comment.Apr 13 2023, 2:19 AM

Could you also add an s8 test case here, just like for G_CTLZ?

stuij accepted this revision.Apr 13 2023, 2:44 AM

Ah right, there's already an s8 test case.
LGTM

This revision is now accepted and ready to land.Apr 13 2023, 2:44 AM
This revision was landed with ongoing or failed builds.Apr 13 2023, 5:38 AM
This revision was automatically updated to reflect the committed changes.