]> git.ipfire.org Git - thirdparty/gcc.git/commit
Extend expand_absneg_bit to vector modes
authorRichard Sandiford <richard.sandiford@arm.com>
Wed, 20 Nov 2024 10:04:46 +0000 (10:04 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Wed, 20 Nov 2024 10:04:46 +0000 (10:04 +0000)
commited6d0867fdbb95691f4054eef6c4b1bd16099700
tree8a0a08ad1241b26b36584ec8ac760d5807d8d7e0
parent0abb5fa523bcc72ec0891813d778b6b47c305f97
Extend expand_absneg_bit to vector modes

Expand can implement NEG and ABS of scalar floating-point modes
by using logic ops to manipulate the sign bit.  This patch extends
that approach to vectors, since it fits relatively easily into the
same structure.

The motivating use case was to inline bf16 NEG and ABS operations
for AArch64.  The patch includes tests for that.

get_absneg_bit_mode required a new opt_mode constructor, so that
opt_mode<T> can be constructed from opt_mode<U> if T is no less
general than U.

gcc/
* machmode.h (opt_mode::opt_mode): New overload.
* optabs-query.h (get_absneg_bit_mode): Declare.
* optabs-query.cc (get_absneg_bit_mode): New function, split
out from expand_absneg_bit.
(can_open_code_p): Use get_absneg_bit_mode.
* optabs.cc (expand_absneg_bit): Likewise.  Take an outer and inner
mode, rather than just one.  Handle vector modes.
(expand_unop, expand_abs_nojump): Update calls accordingly.
Handle vector modes.

gcc/testsuite/
* gcc.target/aarch64/abs_bf_1.c: New test.
* gcc.target/aarch64/neg_bf_1.c: Likewise.
* gcc.target/aarch64/neg_bf_2.c: Likewise.
gcc/machmode.h
gcc/optabs-query.cc
gcc/optabs-query.h
gcc/optabs.cc
gcc/testsuite/gcc.target/aarch64/abs_bf_1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/neg_bf_1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/neg_bf_2.c [new file with mode: 0644]