[InstCombine] use logical-and matcher to avoid crash
authorSanjay Patel <spatel@rotateright.com>
Wed, 2 Nov 2022 12:21:42 +0000 (08:21 -0400)
committerSanjay Patel <spatel@rotateright.com>
Wed, 2 Nov 2022 12:23:52 +0000 (08:23 -0400)
commitb24e2f6ef6704652f52e1dc24e4e1cae5144fb7a
treeb5eb35fa54934915bc6e95c4735052877c179a82
parent6f77979a4b1348d136995644c1f4ad37b50d6580
[InstCombine] use logical-and matcher to avoid crash

Follow-on to:
ec0b406e16c44f1554

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

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