[RISCV] Generalize select (and (x , 0x1) == 0), y, (z ^ y) ) and select (and (x ...
authorPhilip Reames <preames@rivosinc.com>
Mon, 3 Oct 2022 19:54:38 +0000 (12:54 -0700)
committerPhilip Reames <listmail@philipreames.com>
Mon, 3 Oct 2022 20:57:38 +0000 (13:57 -0700)
commite88432414517c8f2e6efa9f02828053e6e25bc6a
treebe628c10eb0f65102626b7dca7a204cbec911d7f
parentdcd02a524befcec71f46ab76d725b2a8f8623d69
[RISCV] Generalize select (and (x , 0x1) == 0), y, (z ^ y) ) and select (and (x , 0x1) == 0), y, (z | y) ) transforms by removing and-clause

These transforms were recently added (by me) in D134881. Looking at the code again, I realized we don't need the (and x, 0x1) portion of the pattern, we just need to know that the result of that sub-tree is either 0 or 1. Checking for this directly allows us to match slightly more broadly. The test changes are zext i1 arguments, but this could also kick in for e.g. shifts of high bits, or any other source of known bits.

Differential Revision: https://reviews.llvm.org/D135081
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/select-binop-identity.ll