This is an archive of the discontinued LLVM Phabricator instance.

Don't generate unnecessary signed ConstantRange during multiply
ClosedPublic

Authored by pete on May 26 2016, 10:07 PM.

Details

Summary

Hi James

In r231483 you taught ConstantRange::multiply to be clever about signed vs unsigned ranges. For example, an unsigned range could be full-set while the signed range is more specific than that.

In looking at the allocations trace for LTO'ing verify-uselistorder, I see millions of allocations from APInt, many of which come from ConstantRange's.

This change tries to avoid some (3.2 million) allocations by returning the unsigned range if its suitable. The checks here are that it should not be a wrapping range, and should be positive. That should be enough to check for ranges such as [1, 10) which the signed range will be equal to, if we were to calculate it.

Thanks,
Pete

Diff Detail

Repository
rL LLVM

Event Timeline

pete updated this revision to Diff 58752.May 26 2016, 10:07 PM
pete retitled this revision from to Don't generate unnecessary signed ConstantRange during multiply.
pete updated this object.
pete added a reviewer: jmolloy.
pete set the repository for this revision to rL LLVM.
pete added a subscriber: llvm-commits.
jmolloy accepted this revision.May 27 2016, 12:26 AM
jmolloy edited edge metadata.

Hi Pete,

This makes sense to me!

James

This revision is now accepted and ready to land.May 27 2016, 12:26 AM
pete closed this revision.May 27 2016, 10:14 AM

Thanks for the quick review! r271020.

Cheers,
Pete

Sorry to dredge this back up. But isn't that only ensuring the lower bound is positive? It doesn't guarantee anything about the upper bound. So I think we are returning full set for [-2, -2] * [0, 1] through the unsigned code and not even checking the signed range.