This is an archive of the discontinued LLVM Phabricator instance.

[LV] Fix miscompile due to srem/sdiv speculation safety condition
ClosedPublic

Authored by reames on Jul 19 2022, 11:42 AM.

Details

Summary

An srem or sdiv has two cases which can cause undefined behavior, not just one. The existing code did not account for this, and as a result, we miscompiled when we encountered e.g. a srem i64 %v, -1 in a conditional block.

Instead of hand rolling the logic, just use the utility function which exists exactly for this purpose.

Diff Detail

Event Timeline

reames created this revision.Jul 19 2022, 11:42 AM
reames requested review of this revision.Jul 19 2022, 11:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 11:42 AM
david-arm accepted this revision.Jul 20 2022, 12:47 AM

LGTM! Nice fix. :)

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
4465

nit: I think this should be 'sensitive'

This revision is now accepted and ready to land.Jul 20 2022, 12:47 AM
This revision was landed with ongoing or failed builds.Jul 20 2022, 5:35 AM
This revision was automatically updated to reflect the committed changes.