This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] use freeze to enable poison-safe logic->select fold
ClosedPublic

Authored by spatel on Oct 22 2022, 6:24 AM.

Details

Summary

Without a freeze, this transform can leak poison to the output:
https://alive2.llvm.org/ce/z/GJuF9i

This makes the transform as uniform as possible, and it can help reduce patterns like issue #58313 (although that particular example probably still needs another transform).

There's a sibling transform just below this one that can be updated as a follow-up if this looks right.

Diff Detail

Event Timeline

spatel created this revision.Oct 22 2022, 6:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2022, 6:24 AM
spatel requested review of this revision.Oct 22 2022, 6:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2022, 6:24 AM
nikic accepted this revision.Oct 22 2022, 7:04 AM

LGTM. If you're looking for more missing logical and/or folds, I've left quite a few !IsLogical breadcrumbs in foldAndOrOfICmps()...

This revision is now accepted and ready to land.Oct 22 2022, 7:04 AM

LGTM. If you're looking for more missing logical and/or folds, I've left quite a few !IsLogical breadcrumbs in foldAndOrOfICmps()...

Thanks! I was just trying to make sure that simple cases like in the bug report don't escape, so probably don't need to go too much further at the moment, but we'll see... :)

This revision was landed with ongoing or failed builds.Oct 22 2022, 7:44 AM
This revision was automatically updated to reflect the committed changes.