This is an archive of the discontinued LLVM Phabricator instance.

[ConstantRange][SCEV] print unsigned ranges
AbandonedPublic

Authored by caojoshua on Feb 18 2023, 11:02 PM.

Details

Summary

Add an option to ConstantRange::print to print underlying APInt as
signed/unsigned number. Teach SCEV to print unsigned ranges. This helps
the human developer understand ranges without doing mental math of
converting signed ranges to unsigned ranges.

Diff Detail

Event Timeline

caojoshua created this revision.Feb 18 2023, 11:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2023, 11:02 PM
caojoshua requested review of this revision.Feb 18 2023, 11:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2023, 11:02 PM

I'm okay with this, but just looking at the test diffs, I'm not sure how helpful this really is... I'd consider a range like [0,-3) to be easier to understand than [0,18446744073709551613), even when interpreting it in an unsigned sense.

I'm okay with this, but just looking at the test diffs, I'm not sure how helpful this really is... I'd consider a range like [0,-3) to be easier to understand than [0,18446744073709551613), even when interpreting it in an unsigned sense.

Yeah, I see what you mean now that I think about it again. I think its helpful for uint8, and maybe uint16, but beyond that the signed version is easier to read. We could add logic to print the unsigned version if its bitwidth is under some threshold, but it feels unnecessary.

I'll close this as won't fix.

caojoshua abandoned this revision.Feb 18 2023, 11:57 PM