This is an archive of the discontinued LLVM Phabricator instance.

[ConstantRange] Add `getClosestToZero()` method - what value[s] are closest to signed zero?
AbandonedPublic

Authored by lebedev.ri on Dec 4 2019, 6:13 AM.

Details

Summary

This method is needed in the follow-up patches adding
ConstantRange::mulWithNoWrap()/ConstantRange::shlWithNoWrap() support
to detect the all-overflow cases where we should/could return empty-set.

There's an exhaustive test so we know this is correct and optimal.

Diff Detail

Event Timeline

lebedev.ri created this revision.Dec 4 2019, 6:13 AM
lebedev.ri updated this revision to Diff 232120.Dec 4 2019, 6:46 AM

Clarify that if we returned two values, they have different polarity, and the negative-one is returned second.

lebedev.ri abandoned this revision.Jan 25 2020, 5:34 AM