[NewGVN] FIx phi-of-ops in the presence of memory read operations
authorNuno Lopes <nuno.lopes@tecnico.ulisboa.pt>
Wed, 26 Jan 2022 10:10:22 +0000 (10:10 +0000)
committerNuno Lopes <nuno.lopes@tecnico.ulisboa.pt>
Wed, 26 Jan 2022 10:19:18 +0000 (10:19 +0000)
commit24a49e99f386432fc6fa46faf6e2ba91cfaed2df
tree00c5928341af30990408cfcea8799d14befcbecf
parent66c602be25c15ca69f6c3a618427ba0237c0d4a9
[NewGVN] FIx phi-of-ops in the presence of memory read operations

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.

Fixes https://llvm.org/PR53277

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D117999
llvm/lib/Transforms/Scalar/NewGVN.cpp
llvm/test/Transforms/NewGVN/phi-of-ops-loads.ll
llvm/test/Transforms/NewGVN/storeoverstore.ll