[CodeGen] Canonicalise adds/subs of i1 vectors using XOR
authorDavid Sherwood <david.sherwood@arm.com>
Mon, 22 Feb 2021 16:00:38 +0000 (16:00 +0000)
committerDavid Sherwood <david.sherwood@arm.com>
Thu, 25 Feb 2021 10:31:26 +0000 (10:31 +0000)
commit87dbcd88651a4e72fc8f5e1594f9b02232277301
treec9ae8f7664b2fe3b1afda3431b7049a4432ced1d
parent201ada80ee15aed23728500982857ad3769f6802
[CodeGen] Canonicalise adds/subs of i1 vectors using XOR

When calling SelectionDAG::getNode() to create an ADD or SUB
of two vectors with i1 element types we can canonicalise this
to use XOR instead, where 1+1 is treated as wrapping around
to 0 and 0-1 wraps to 1.

I've added the following tests for SVE targets:

  CodeGen/AArch64/sve-pred-arith.ll

and modified some X86 tests to reflect the much simpler codegen
required.

Differential Revision: https://reviews.llvm.org/D97276
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/test/CodeGen/AArch64/sve-pred-arith.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/avx512-mask-op.ll
llvm/test/CodeGen/X86/avx512bw-mask-op.ll