[InstCombine] add folds for binop with sexted bool and constant operands
authorSanjay Patel <spatel@rotateright.com>
Sat, 20 Nov 2021 15:55:41 +0000 (10:55 -0500)
committerSanjay Patel <spatel@rotateright.com>
Sat, 20 Nov 2021 17:33:00 +0000 (12:33 -0500)
commit337948ac6e2260fc4d5a1901b4f667a2a0a52ee3
treee20728cbdf06c8aeb056609249f07654b164c1c5
parent1d007d0e5a929c3f5cb25aea18d6c8a16326c02e
[InstCombine] add folds for binop with sexted bool and constant operands

This is a generalization/extension of the existing and/or
folds noted with TODO comments. Those have a one-use
constraint that is not necessary.

Potential follow-ups are noted by the TODO comments in
the new function. We can also call this function from
other binop visit* functions, but we need to add tests
first.

This solves:
https://llvm.org/PR52543

https://alive2.llvm.org/ce/z/NWuCR5
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/and.ll
llvm/test/Transforms/InstCombine/or.ll