[PATCH] D97495: [SimplifyCFG] avoid illegal phi with both poison and undef

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 26 08:08:11 PST 2021


aqjune added a comment.

In D97495#2590004 <https://reviews.llvm.org/D97495#2590004>, @spatel wrote:

> In D97495#2589631 <https://reviews.llvm.org/D97495#2589631>, @aqjune wrote:
>
>> What about updating redirectValuesFromPredecessorsToPhi to lower conflicting poison to undef?
>> We can maintain two sets of incoming BBs, say BBundef and BBpoison that have poison incoming values and undef incoming values.
>> At the end of redirectValuesFromPredecessorsToPhi, if BBundef and BBpoison overlaps, there are operands that need to be updated.
>> It will keep the transformation enabled.
>
> Yes, we can do better on this, but I suspect it's rare to encounter both poison and undef (and gets more rare as we eliminate more and more undef from IR?).

I think it won't be very rare ATM because there are quite a few places that create poison constants.

Maybe we can create a new function that 'sanitizes' operands in PHI: it checks whether a PHI has multiple incoming edges with different undef/poison constants, and if there's any, replace such poison constants with undefs.

  p = phi [ undef, BB ], [ poison, BB ]
    -> PHINode::sanitize (or something like this, I guess this isn't the best name)
  p = phi [ undef,  BB ], [ undef, BB ]

If a new bug that's similar to this issue is reported, we can simply add a call to this function and it will fix the bug.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97495/new/

https://reviews.llvm.org/D97495



More information about the llvm-commits mailing list