This is an archive of the discontinued LLVM Phabricator instance.

[TargetLowering] Expand the last stage of i16 popcnt using shift+add+and instead of mul+shift.
ClosedPublic

Authored by craig.topper on May 15 2022, 11:17 AM.

Details

Summary

If we use multiply it would be with 0x0101 which is 1 more than a power
of 2. On some targets we would expand this to shl+add. By avoiding the
multiply earlier, we can generate better code.

Note, PowerPC doesn't do the shl+add expansion of multiply so one of
the tests increased in instruction count.

Limiting to scalars because it almost always increased the number of
instructions in vector tests.

Diff Detail

Event Timeline

craig.topper created this revision.May 15 2022, 11:17 AM
craig.topper requested review of this revision.May 15 2022, 11:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2022, 11:17 AM
RKSimon accepted this revision.May 16 2022, 4:06 AM

LGTM

This revision is now accepted and ready to land.May 16 2022, 4:06 AM
This revision was landed with ongoing or failed builds.May 16 2022, 9:38 AM
This revision was automatically updated to reflect the committed changes.