[PATCH] D132671: [RISCV] Teach combineDeMorganOfBoolean to handle (and (xor X, 1), (not Y)).

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 09:27:12 PDT 2022


craig.topper created this revision.
craig.topper added reviewers: reames, luismarques, asb, kito-cheng.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, frasercrmck, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

SimplifyDemandedBits tries to agressively turn xor immediates into -1
to match a 'not' instruction. In this case, because X is a boolean, the
upper bits of (xor X, 1) are known to be 0. Because this is an AND
instruction, that means those bits aren't demanded from the other
operand, and thus SimplifyDemandedBits can turn (xor Y, 1) to (not Y).

We need to detect that this has happened to enable the DeMorgan
optimization. To do this we allow one of the xors to use -1 when
the outer operation is And.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132671

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/double-previous-failure.ll
  llvm/test/CodeGen/RISCV/setcc-logic.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132671.455619.patch
Type: text/x-patch
Size: 4860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220825/aad4b602/attachment-0001.bin>


More information about the llvm-commits mailing list