This is an archive of the discontinued LLVM Phabricator instance.

Fix _BitInt suffix width calculation
ClosedPublic

Authored by aaron.ballman on Mar 22 2022, 6:50 AM.

Details

Summary

@mgehre-amd pointed out the following post-commit review feedback on the changes in 8cba72177dcd8de5d37177dbaf2347e5c1f0f1e8:

As an example, the paper says 3wb /* Yields an _BitInt(3); two value bits, one sign bit */.
So I would expect that 0xFwb gives _BitInt(5); four value bits, one sign bit, but with this implementation I get _BitInt(2).
This is because ResultVal as 4 bits, and getMinSignedBits() inteprets it as negative and thus says that 1 bit is enough to represent -1.

This corrects the behavior for calculating the bit-width and adds some test coverage.

Diff Detail

Event Timeline

aaron.ballman created this revision.Mar 22 2022, 6:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2022, 6:50 AM
aaron.ballman requested review of this revision.Mar 22 2022, 6:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2022, 6:50 AM
erichkeane accepted this revision.Mar 22 2022, 6:52 AM
This revision is now accepted and ready to land.Mar 22 2022, 6:52 AM
mgehre-amd accepted this revision.Mar 22 2022, 6:54 AM

Thanks a lot!

aaron.ballman closed this revision.Mar 22 2022, 7:02 AM

Thanks for the quick reviews, and thanks for catching the issue @mgehre-amd! I've committed in 9cf8f81ca45de198013f29442a7de6600b226d70.