This is an archive of the discontinued LLVM Phabricator instance.

[NewGVN] FIx phi-of-ops in the presence of memory read operations
ClosedPublic

Authored by nlopes on Jan 23 2022, 11:19 AM.

Details

Summary

The phi-of-ops functionality has a function OpIsSafeForPHIOfOps to determine when it's safe to create the new phi. But this function only checks for the obvious dominator conditions and ignores memory.
This patch takes the conservative approach and disables phi-of-ops whenever there's a load that doesn't dominate the phi, as its value may be affected by a store inside the loop.

This can be improved later to check aliasing between the load/stores. I've added a few tests that show the missed cases.

fixes https://github.com/llvm/llvm-project/issues/53277

Diff Detail

Event Timeline

nlopes created this revision.Jan 23 2022, 11:19 AM
nlopes requested review of this revision.Jan 23 2022, 11:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 23 2022, 11:19 AM
asbirlea accepted this revision.Jan 25 2022, 5:13 PM

Thank you for sending this fix!
It feels like a pretty big hammer, but some of the tests being modified here are exact examples of the miscompile I was seeing. I'm good with it at this point.

This revision is now accepted and ready to land.Jan 25 2022, 5:13 PM