This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking][ConstantRange] Distinguish low/high always overflow
ClosedPublic

Authored by nikic on May 26 2019, 6:49 AM.

Details

Summary

In order to fold an always overflowing signed saturating add/sub, we need to know in which direction the always overflow occurs. This patch splits up AlwaysOverflows into AlwaysOverflowsLow and AlwaysOverflowsHigh to pass through this information (but it is not used yet).

Diff Detail

Event Timeline

nikic created this revision.May 26 2019, 6:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2019, 6:49 AM
lebedev.ri added inline comments.May 26 2019, 12:33 PM
llvm/include/llvm/Analysis/ValueTracking.h
416

These now need a comment for each.
While with the enum on the LHS of the diff it is obvious,
here i'm not sure what low/high means.
The direction of the overflow?

nikic updated this revision to Diff 201465.May 26 2019, 12:49 PM

Add comments for enum cases.

nikic marked an inline comment as done.May 26 2019, 12:54 PM
nikic added inline comments.
llvm/include/llvm/Analysis/ValueTracking.h
416

Yeah, this is the direction of overflow. For AlwaysOverflowLow the real result would be lower than signed/unsigned min, for AlwaysOverflowHigh it would be higher than signed/unsigned max.

lebedev.ri accepted this revision.May 27 2019, 11:54 AM

Looks reasonable.

llvm/include/llvm/Analysis/ValueTracking.h
416

Thanks. Hmm, still a bit confusing, maybe adding a simple examples could help. Or not.

llvm/lib/IR/ConstantRange.cpp
1211

overflows low

This revision is now accepted and ready to land.May 27 2019, 11:54 AM
nikic marked an inline comment as done.May 27 2019, 12:04 PM
nikic added inline comments.
llvm/lib/IR/ConstantRange.cpp
1211

What do you mean by this comment? The unsigned add is an overflow high case.

This revision was automatically updated to reflect the committed changes.