Page MenuHomePhabricator

[ConstantRange] Clarify makeGuaranteedNoWrapRegion() guarantees
ClosedPublic

Authored by nikic on Apr 12 2019, 12:32 AM.

Details

Summary

makeGuaranteedNoWrapRegion() is actually makeExactNoWrapRegion() as long as only one of NUW or NSW is specified. This is not obvious from the current documentation, and some code seems to think that it is only exact for single-element ranges. Clarify docs and add tests to be more confident this really holds.

There are currently no users of makeGuaranteedNoWrapRegion() that pass both NUW and NSW. I think it would be best to drop support for this entirely and then rename the function to makeExactNoWrapRegion().

Knowing that the no-wrap region is exact is useful, because we can backwards-constrain values. What I have in mind in particular is that LVI should be able to constrain values on edges where the with.overflow overflow flag is false.

Diff Detail

Repository
rL LLVM

Event Timeline

nikic created this revision.Apr 12 2019, 12:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2019, 12:32 AM
lebedev.ri accepted this revision.Apr 12 2019, 12:00 PM

This is NFC since it only clarifies docs and adds respective test coverage, thanks.

llvm/unittests/IR/ConstantRangeTest.cpp
1177–1178 ↗(On Diff #194809)

Can we test/guarantee anything about the subset that will be returned if both are specified?
Naive guess - the most constrained range will be returned, the NSW one?

This revision is now accepted and ready to land.Apr 12 2019, 12:00 PM
This revision was automatically updated to reflect the committed changes.
nikic marked an inline comment as done.