[InstCombine] allow vector splat matching for bitwise logic fold
authorSanjay Patel <spatel@rotateright.com>
Mon, 1 Nov 2021 15:35:41 +0000 (11:35 -0400)
committerSanjay Patel <spatel@rotateright.com>
Mon, 1 Nov 2021 15:39:48 +0000 (11:39 -0400)
commit42c94bc1abd1029c35846fd500a8b2bb008fef73
tree8cb52bb705a7b702f6370a5b2e0d70763e3daddb
parentbeb5396d52d83dc9ccec8a427e12122cb33baf9d
[InstCombine] allow vector splat matching for bitwise logic fold

Similar to 54e969cffddb (and with cosmetic updates to hopefully
make that easier to read), this fold has been around since early
in LLVM history.

Intermediate folds have been added subsequently, so extra uses
are required to exercise this code.

The test example actually shows an unintended consequence with
extra uses - we end up with an extra instruction compared to what
we started with. But this at least makes scalar/vector consistent.

General proof:
https://alive2.llvm.org/ce/z/tmuBza
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/and-or.ll