This is an archive of the discontinued LLVM Phabricator instance.

[BasicAA] Handle known bits as ranges
ClosedPublic

Authored by nikic on Oct 27 2021, 3:59 AM.

Details

Summary

BasicAA currently tries to determine that the offset is positive by checking whether all variable indices are positive based on known bits, multiplied by a positive scale. However, this is incorrect if the scale multiplication might overflow. In the modified test case the original value is positive, but may be negative after a left shift.

Fix this by converting known bits into a constant range and reusing the range-based logic, which handles overflow correctly.

Diff Detail

Event Timeline

nikic created this revision.Oct 27 2021, 3:59 AM
nikic requested review of this revision.Oct 27 2021, 3:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2021, 3:59 AM
courbet accepted this revision.Oct 27 2021, 5:24 AM

Nice to see all these special cases converging.

This revision is now accepted and ready to land.Oct 27 2021, 5:24 AM
This revision was landed with ongoing or failed builds.Oct 27 2021, 5:41 AM
This revision was automatically updated to reflect the committed changes.