This is an archive of the discontinued LLVM Phabricator instance.

[ConstantRange] Add support of mul in makeGuaranteedNoWrapRegion.
ClosedPublic

Authored by timshen on Jun 20 2018, 3:47 PM.

Event Timeline

timshen created this revision.Jun 20 2018, 3:47 PM
timshen updated this revision to Diff 152189.Jun 20 2018, 3:51 PM

Add comments for div round up/down.

timshen updated this revision to Diff 152195.Jun 20 2018, 4:06 PM

Remove extra braces.

timshen updated this revision to Diff 152216.Jun 20 2018, 7:03 PM

Formatting.

sanjoy requested changes to this revision.Jun 21 2018, 10:01 PM
sanjoy added inline comments.
llvm/lib/IR/ConstantRange.cpp
269

Sorry for being difficult, but these should live on APInt and be individually unit-tested.

335

Can you please given an informal description of how this works? For example, naively I'd think for unsigned overflow just checking [0,Other.getUnsignedMax()) would be sufficient.

This revision now requires changes to proceed.Jun 21 2018, 10:01 PM
timshen updated this revision to Diff 152520.Jun 22 2018, 11:02 AM

Factored out APInt code, and simplified unsigned code.

timshen marked 2 inline comments as done.Jun 22 2018, 11:02 AM
sanjoy accepted this revision.Jun 26 2018, 11:31 AM

LGTM modulo comments on the test coverage inline.

I didn't check the math too carefully since the test coverage looks good.

llvm/unittests/IR/ConstantRangeTest.cpp
1024

All of these tests would have passed without your change right (since earlier we'd return an empty range for multiplication)?

If yes, maybe add a couple of tests that check that we return non-trivial results (i.e. not empty sets) for some inputs?

1051

Maybe add an /*isSigned=*/true here?

1056

Minor nit, but it looks like these three loops can be different test cases with more descriptive names.

This revision is now accepted and ready to land.Jun 26 2018, 11:31 AM
timshen updated this revision to Diff 152929.Jun 26 2018, 11:41 AM
timshen marked an inline comment as done.

Updated comments and style.

timshen marked an inline comment as done.Jun 26 2018, 11:41 AM
timshen added inline comments.
llvm/unittests/IR/ConstantRangeTest.cpp
1024

All of these tests would have passed without your change right (since earlier we'd return an empty range for multiplication)?

No they don't pass. These tests test the inverse cases too, e.g. "iff" instead of "if". Looking at EXPECT_EQ(!Overflow, Range.contains(...));, if Overflow is false and Range is empty, the test will fail.

timshen updated this revision to Diff 152930.Jun 26 2018, 11:45 AM

Add missing typedef.

This revision was automatically updated to reflect the committed changes.