This is an archive of the discontinued LLVM Phabricator instance.

[MergeICmps] Relax sinking check
ClosedPublic

Authored by nikic on Jul 22 2021, 1:28 PM.

Details

Summary

The check for sinking instructions past the load + cmp sequence currently checks for side-effects, which includes writing to memory and unwinding. However, I don't believe we care about sinking the instructions past an unwind (as they don't have any side-effects themselves).

Noticed this will reviewing uses of mayHaveSideEffect() for an upcoming change.

Diff Detail

Event Timeline

nikic created this revision.Jul 22 2021, 1:28 PM
nikic requested review of this revision.Jul 22 2021, 1:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2021, 1:28 PM

I'm not sure about the nounwind: If the function does raise a exception, we can't know that it's fine to read past the first pair of elements.

I'm not sure about the nounwind: If the function does raise a exception, we can't know that it's fine to read past the first pair of elements.

The transform here is the other way around though: The loads are sunk below the other instructions. So we will do less loads if an unwind occurs, not more. As we checked that the loads are simple, that should be legal.

courbet accepted this revision.Jul 23 2021, 12:15 AM

I'm not sure about the nounwind: If the function does raise a exception, we can't know that it's fine to read past the first pair of elements.

The transform here is the other way around though: The loads are sunk below the other instructions. So we will do less loads if an unwind occurs, not more. As we checked that the loads are simple, that should be legal.

Ah, yes, right. Great !

This revision is now accepted and ready to land.Jul 23 2021, 12:15 AM
This revision was landed with ongoing or failed builds.Jul 23 2021, 1:16 PM
This revision was automatically updated to reflect the committed changes.