]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: Fix bogus cnot optimisation [PR114603]
authorRichard Sandiford <richard.sandiford@arm.com>
Fri, 5 Apr 2024 13:47:15 +0000 (14:47 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Fri, 5 Apr 2024 13:47:15 +0000 (14:47 +0100)
commit67cbb1c638d6ab3a9cb77e674541e2b291fb67df
tree20aec7a29ba46975301a814b856e5c5f3881bf41
parente4d074321bcafa6504ee6b77754b4450a4622f9d
aarch64: Fix bogus cnot optimisation [PR114603]

aarch64-sve.md had a pattern that combined:

cmpeq pb.T, pa/z, zc.T, #0
mov zd.T, pb/z, #1

into:

cnot zd.T, pa/m, zc.T

But this is only valid if pa.T is a ptrue.  In other cases, the
original would set inactive elements of zd.T to 0, whereas the
combined form would copy elements from zc.T.

gcc/
PR target/114603
* config/aarch64/aarch64-sve.md (@aarch64_pred_cnot<mode>): Replace
with...
(@aarch64_ptrue_cnot<mode>): ...this, requiring operand 1 to be
a ptrue.
(*cnot<mode>): Require operand 1 to be a ptrue.
* config/aarch64/aarch64-sve-builtins-base.cc (svcnot_impl::expand):
Use aarch64_ptrue_cnot<mode> for _x operations that are predicated
with a ptrue.  Represent other _x operations as fully-defined _m
operations.

gcc/testsuite/
PR target/114603
* gcc.target/aarch64/sve/acle/general/cnot_1.c: New test.
gcc/config/aarch64/aarch64-sve-builtins-base.cc
gcc/config/aarch64/aarch64-sve.md
gcc/testsuite/gcc.target/aarch64/sve/acle/general/cnot_1.c [new file with mode: 0644]