[InstCombine] use freeze to enable poison-safe logic->select fold
authorSanjay Patel <spatel@rotateright.com>
Sat, 22 Oct 2022 14:12:34 +0000 (10:12 -0400)
committerSanjay Patel <spatel@rotateright.com>
Sat, 22 Oct 2022 14:42:14 +0000 (10:42 -0400)
commit8628e6df70008e3eba86aee2a128b2e9b1f7cc26
treedbafa8657035deedf3cceb1fee354ea67ba456a3
parentdb40f9b77417aa0d5be2200a4972e5f696ab7c34
[InstCombine] use freeze to enable poison-safe logic->select fold

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).

Differential Revision: https://reviews.llvm.org/D136527
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select-safe-transforms.ll