This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Fix poison safety in insertvalue fold
ClosedPublic

Authored by nikic on Feb 15 2023, 7:48 AM.

Details

Summary

We can only fold insertvalue undef, (extractvalue x, n) to x if x is not poison, otherwise we might be replacing undef with poison (https://alive2.llvm.org/ce/z/fnw3c8). The insertvalue poison case is always fine.

I didn't go to particularly large effort to preserve cases where folding with undef is still legal (mainly when there is a chain of multiple inserts that end up covering the whole aggregate), because this shouldn't really occur in practice: We should always be generating the insertvalue poison form when constructing aggregates nowadays.

Diff Detail

Event Timeline

nikic created this revision.Feb 15 2023, 7:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2023, 7:48 AM
nikic requested review of this revision.Feb 15 2023, 7:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2023, 7:48 AM
nlopes accepted this revision.Feb 15 2023, 7:55 AM

This is great, thank you!

I think this is safe by now; we've removed most insertvalues with undef by now.

This revision is now accepted and ready to land.Feb 15 2023, 7:55 AM
spatel accepted this revision.Feb 15 2023, 8:19 AM

LGTM

This revision was landed with ongoing or failed builds.Feb 16 2023, 12:39 AM
This revision was automatically updated to reflect the committed changes.