This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking][SelectionDAG] Rename ComputeMinSignedBits->ComputeMaxSignificantBits. NFC
ClosedPublic

Authored by craig.topper on Jan 2 2022, 11:44 PM.

Details

Summary

This function returns an upper bound on the number of bits needed
to represent the signed value. Use "Max" to match similar functions
in KnownBits like countMaxActiveBits.

Rename APInt::getMinSignedBits->getSignificantBits. Keeping the old
name around to keep this patch size down. Will do a bulk rename as
follow up.

Rename KnownBits::countMaxSignedBits->countMaxSignificantBits.

Diff Detail

Event Timeline

craig.topper created this revision.Jan 2 2022, 11:44 PM
craig.topper requested review of this revision.Jan 2 2022, 11:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 2 2022, 11:44 PM
lebedev.ri accepted this revision.Jan 2 2022, 11:54 PM
This revision is now accepted and ready to land.Jan 2 2022, 11:54 PM
RKSimon accepted this revision.Jan 3 2022, 4:16 AM

LGTM - with one (very pedantic) minor

llvm/include/llvm/Analysis/ValueTracking.h
204–205

The use of minimum might be confusing - please can you tweak the description?

llvm/include/llvm/CodeGen/SelectionDAG.h
1835–1836

Tweak the description?

1841–1842

Tweak the description?

Tweak comments.

Use ComputeMaxSignificantBits instead.

craig.topper requested review of this revision.Jan 3 2022, 10:54 AM
craig.topper retitled this revision from [ValueTracking][SelectionDAG] Rename ComputeMinSignedBits->ComputeMaxSignedBits. NFC to [ValueTracking][SelectionDAG] Rename ComputeMinSignedBits->ComputeMaxSignificantBits. NFC.
craig.topper edited the summary of this revision. (Show Details)
spatel accepted this revision.Jan 3 2022, 11:09 AM

LGTM - someday we might fix the capitalization of function names too. :)

llvm/include/llvm/Analysis/ValueTracking.h
214

That should be "APInt::getSignificantBits function" (no "Max")?

llvm/include/llvm/CodeGen/SelectionDAG.h
1838

That should be "APInt::getSignificantBits function" (no "Max")?

This revision is now accepted and ready to land.Jan 3 2022, 11:09 AM
This revision was landed with ongoing or failed builds.Jan 3 2022, 11:33 AM
This revision was automatically updated to reflect the committed changes.
foad added a comment.Jan 4 2022, 1:19 AM

Rename APInt::getMinSignedBits->getSignificantBits

Why drop "Signed" from the name? Now we have getActiveBits for the unsigned version of this functionality and getSignificantBits for the signed version, which I don't think is very intuitive.

spatel added a comment.Jan 4 2022, 6:03 AM

Rename APInt::getMinSignedBits->getSignificantBits

Why drop "Signed" from the name? Now we have getActiveBits for the unsigned version of this functionality and getSignificantBits for the signed version, which I don't think is very intuitive.

Good point. So we should standardize on either "active" or "significant". Go with "active" since it already exists and is shorter?
We could also standardize the verb in these names. Currently, it is "get", "count", or "compute".
If we unify those, it could be something like this across all of these APIs:
get[Max]ActiveBitsSigned()
get[Max]ActiveBitsUnsigned()

Rename APInt::getMinSignedBits->getSignificantBits

Why drop "Signed" from the name? Now we have getActiveBits for the unsigned version of this functionality and getSignificantBits for the signed version, which I don't think is very intuitive.

Good point. So we should standardize on either "active" or "significant". Go with "active" since it already exists and is shorter?
We could also standardize the verb in these names. Currently, it is "get", "count", or "compute".
If we unify those, it could be something like this across all of these APIs:
get[Max]ActiveBitsSigned()
get[Max]ActiveBitsUnsigned()

I don't think we should apply the "Active" term to signed. In my head Active is kind of associated with bits that are ones. There's also APIntgetActiveWords that is implemented using getActiveBits to determine the last word that has ones in it.