This is an archive of the discontinued LLVM Phabricator instance.

[LICM] Allow load-only scalar promotion in the presence of unwinding
ClosedPublic

Authored by nikic on Sep 1 2022, 7:18 AM.

Details

Summary

Currently, we bail out of scalar promotion if the loop may unwind and the memory may be visible on unwind. This is because we can't insert stores of the promoted value on unwind edges.

However, nowadays scalar promotion also has support for only promoting loads, while leaving stores in place. This kind of promotion is safe even in the presence of unwinding.

(The next and more interesting step is that we can also allow potentially aliasing reads of the pointer when doing load-only promotion.)

Diff Detail

Event Timeline

nikic created this revision.Sep 1 2022, 7:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2022, 7:18 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikic requested review of this revision.Sep 1 2022, 7:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2022, 7:18 AM

Very interesting. This looks good to me. Thanks.

djtodoro added inline comments.Sep 1 2022, 8:19 AM
llvm/lib/Transforms/Scalar/LICM.cpp
1962
enum class?
reames accepted this revision.Sep 1 2022, 9:18 AM

LGTM w/minor comment.

llvm/lib/Transforms/Scalar/LICM.cpp
1962

Can you add a quick comment which emphasizes this is a lattice and not an optional bool? That is, once it falls from unknown to known, it's not every legal to transition from unsafe to safe?

llvm/test/Transforms/LICM/scalar-promote-unwind.ll
471

Update comment

This revision is now accepted and ready to land.Sep 1 2022, 9:18 AM
This revision was automatically updated to reflect the committed changes.
nikic marked 2 inline comments as done.