This is an archive of the discontinued LLVM Phabricator instance.

[ValueLattice] Steal bits from Tag to track range extensions (NFC).
ClosedPublic

Authored by fhahn on Apr 14 2020, 12:55 PM.

Details

Summary

Users of ValueLatticeElement currently have to ensure constant ranges
are not extended indefinitely. For example, in SCCP, mergeIn goes to
overdefined if a constantrange value is repeatedly merged with larger
constantranges. This is a simple form of widening.

In some cases, this leads to an unnecessary loss of information and
things can be improved by allowing a small number of extensions in the
hope that a fixed point is reached after a small number of steps.

To make better decisions about widening, it is helpful to keep track of
the number of range extensions. That state is tied directly to a
concrete ValueLatticeElement and some unused bits in the class can be
used. The current patch preserves the existing behavior by default:
CheckWiden defaults to false and if CheckWiden is true, a single change
to the range is allowed.

Follow-up patches will slightly increase the threshold for widening.

Diff Detail

Event Timeline

fhahn created this revision.Apr 14 2020, 12:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2020, 12:55 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
This revision is now accepted and ready to land.Apr 14 2020, 1:09 PM
fhahn updated this revision to Diff 258316.Apr 17 2020, 7:13 AM

Rebased

nikic added a subscriber: nikic.Apr 17 2020, 7:47 AM
nikic added inline comments.
llvm/include/llvm/Analysis/ValueLattice.h
78–80

Why 6? I would expect either 3 here (because that's enough to represent the states) or 8 (an ISA friendly number).

This revision was automatically updated to reflect the committed changes.
fhahn marked an inline comment as done.Apr 17 2020, 9:20 AM
fhahn added inline comments.
llvm/include/llvm/Analysis/ValueLattice.h
78–80

The main intention was to leave enough space for plenty of further extension while keeping plenty of other bits for other stuff. But it's probably worth to extend it to 8. I'll do that as a follow up commit.