[InstCombine] use logical-or matcher to avoid crash
authorSanjay Patel <spatel@rotateright.com>
Tue, 1 Nov 2022 20:26:20 +0000 (16:26 -0400)
committerSanjay Patel <spatel@rotateright.com>
Tue, 1 Nov 2022 20:47:41 +0000 (16:47 -0400)
commitec0b406e16c44f1554e409b20ba6d7a76e3fe08d
tree9d1ad70510182766f00a375d29288badd5145df3
parent29661fe94bf12ced1f99c80914c3c87ba4198ab4
[InstCombine] use logical-or matcher to avoid crash

This should prevent crashing for the example in issue #58552
by not matching a select-of-vectors-with-scalar-condition.

A similar change is likely needed for the related fold to
properly fix that kind of bug.

The test that shows a regression seems unlikely to occur
in real code.

This also picks up an optimization in the case where a real
(bitwise) logic op is used. We could already convert some
similar select ops to real logic via impliesPoison(), so
we don't see more diffs on commuted tests. Using commutative
matchers (when safe) might also handle one of the TODO tests.
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select-safe-transforms.ll