This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Remove memset of undef value
ClosedPublic

Authored by nikic on Apr 21 2022, 7:15 AM.

Details

Summary

This removes memset with undef char. We already do this for stores of undef value.

This comes with the caveat that this optimization is not, strictly speaking, legal for undef values, because we might be overwriting a poison value. However, our entire load/store model currently still operates on undef values, so we need to support undef here as well for internal consistency. Once https://github.com/llvm/llvm-project/issues/52930 is resolved, these and related folds can be limited to poison -- I've added FIXMEs to that effect.

Diff Detail

Event Timeline

nikic created this revision.Apr 21 2022, 7:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2022, 7:15 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikic requested review of this revision.Apr 21 2022, 7:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2022, 7:15 AM

Ping. My fallback plan here is to add this to MemCpyOpt instead and apply it only if the target memory is uninitialized (and thus already undef). I think that would be the worse option though.

nlopes accepted this revision.Apr 29 2022, 1:27 AM

Well, I think this is ok. It's not regressing behavior vs undef store removal. So if this is important for Rust, let's maybe keep it,
Fingers crossed that the GSoC student will make good progress on the uninitialized memory thing.

This revision is now accepted and ready to land.Apr 29 2022, 1:27 AM
This revision was landed with ongoing or failed builds.Apr 29 2022, 5:51 AM
This revision was automatically updated to reflect the committed changes.