This is an archive of the discontinued LLVM Phabricator instance.

[ConstantRange] [a, b) udiv a full range is [0, umax(b)).
ClosedPublic

Authored by fhahn on Apr 10 2019, 1:01 PM.

Event Timeline

fhahn created this revision.Apr 10 2019, 1:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 10 2019, 1:01 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
fhahn added a comment.Apr 10 2019, 1:07 PM

The main problem this patch addresses is the RHS == full-set case, where we exit early.

nikic added inline comments.Apr 10 2019, 1:28 PM
llvm/lib/IR/ConstantRange.cpp
1015

This full set check looks pretty bogus to me The result of CR1 udiv CR2 should be some subset of [0, umax(CR1)], as you won't get back a larger value from a division. Your patch makes [0, 1) udiv full-set return [0, 1), but there are also other cases where the current code is inaccurate:

[0, 5) udiv full-set should be [0, 5)
[5, 10) udiv full-set should be [0, 10)

Would it be possible to just drop this check?

Reverse ping

fhahn updated this revision to Diff 196471.Apr 24 2019, 9:25 AM

Generalize patch to handle [a, b) udiv full set == [0, b).

fhahn marked an inline comment as done.Apr 24 2019, 9:26 AM
fhahn added inline comments.
llvm/lib/IR/ConstantRange.cpp
1015

Not sure why the check was there in the first place! It looks like we can generalize the handling and drop it.

nikic accepted this revision.Apr 24 2019, 9:31 AM

LGTM

This revision is now accepted and ready to land.Apr 24 2019, 9:31 AM
fhahn retitled this revision from [ConstantRange] [0, 1) divided by non-empty ranges is [0, 1). to [ConstantRange] [a, b) udiv a full range is [0, umax(b))..Apr 24 2019, 12:26 PM
This revision was automatically updated to reflect the committed changes.