phi([undef, A], [x, B]) -> x is only correct x is guaranteed to be a non-poison value. Otherwise we would be changing an undef to poison in the branch A.
This patch fixes this bug in NewGVN.
Paths
| Differential D117907
[NewGVN] do phi(undef, x) -> x only if x is not poison ClosedPublic Authored by nlopes on Jan 21 2022, 9:36 AM.
Details Summary phi([undef, A], [x, B]) -> x is only correct x is guaranteed to be a non-poison value. Otherwise we would be changing an undef to poison in the branch A. This patch fixes this bug in NewGVN.
Diff Detail
Event TimelineThis revision is now accepted and ready to land.Jan 25 2022, 4:30 PM Comment Actions It looks like the current behavior matches what GVN does: https://llvm.godbolt.org/z/eTYzMjKf7 If an issue affects both GVN and NewGVN, please always fix it in GVN first. Otherwise the fix will remain untested, and this seems like a situation where it can cause a real regression in optimization quality (because we still treat uninit loads as undef, not poison). This revision now requires changes to proceed.Jan 26 2022, 12:15 AM Comment Actions
The bug is not in GVN itself, it's in InstSimplify (which is called by GVNPass::processInstruction). Comment Actions
@nikic do you agree with this plan (commit this patch now and fix InstSimplify after 14 branches in a few weeks)? This revision was not accepted when it landed; it landed in state Needs Revision.Jan 29 2022, 1:44 PM This revision was landed with ongoing or failed builds. Closed by commit rGf1c18acb07aa: [NewGVN] do phi(undef, x) -> x only if x is not poison (authored by nlopes). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 402022 llvm/lib/Transforms/Scalar/NewGVN.cpp
llvm/test/Transforms/NewGVN/completeness.ll
llvm/test/Transforms/NewGVN/phi-edge-handling.ll
llvm/test/Transforms/NewGVN/pr31682.ll
llvm/test/Transforms/NewGVN/pr32403.ll
llvm/test/Transforms/NewGVN/pr32838.ll
llvm/test/Transforms/NewGVN/pr34135.ll
|