[InstCombine] reduce redundant code for shl-binop folds
authorSanjay Patel <spatel@rotateright.com>
Tue, 28 Sep 2021 20:59:18 +0000 (16:59 -0400)
committerSanjay Patel <spatel@rotateright.com>
Tue, 28 Sep 2021 21:06:45 +0000 (17:06 -0400)
commit98fde3489a6d9ed3fa409623036e5ba5b99f1404
tree18dd6ba7046af5bc9cbd73147a37b4e6e5848720
parent6c1a58fe51bc41e28371132380ccd4a8cd2e3e11
[InstCombine] reduce redundant code for shl-binop folds

This is NFCI (no-functional-change-intended), but there
are benign diffs possible with commutable ops as seen in
the test diffs.

The transforms were repeated for the commutative opcodes,
but that should not be necessary if we canonicalize the
patterns that we're matching. If both operands of the
binop match, that should get folded eventually.

The transform that starts with a mask op seems to
over-constrain the use checks, so that could be a
potential enhancement.
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/test/Transforms/InstCombine/shl-bo.ll