https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117013
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Christophe Lyon <cl...@gcc.gnu.org>: https://gcc.gnu.org/g:fabbf99fc8ae26f0d87ff0c8619b4fc3bb4a5da2 commit r16-83-gfabbf99fc8ae26f0d87ff0c8619b4fc3bb4a5da2 Author: Spencer Abson <spencer.ab...@arm.com> Date: Thu Jan 23 19:48:49 2025 +0000 AArch64: Define the spaceship optab [PR117013] This expansion ensures that exactly one comparison is emitted for spacesip-like sequences on floating-point operands, including when the result of such sequences are compared against members of std::<some_ordering>::<some_value>. For both integer and floating-point types, we optimize for the case in which the result of a spaceship-like operation is written to a GPR. The PR highlights this issue for floating-point operands, but we also make an improvement for integers, preferring: cmp w0, w1 cset w1, gt csinv w0, w1, wzr, ge over: cmp w0, w1 mov w0, 1 csinv w0, w0, wzr, ge csel w0, w0, wzr, ne to compute: auto test(int a, int b) { return a <=> b;} gcc/ChangeLog: PR target/117013 * config/aarch64/aarch64-protos.h (aarch64_expand_fp_spaceship): Declare optab expander function for floating-point types. * config/aarch64/aarch64.cc (aarch64_expand_fp_spaceship): Define optab expansion for floating-point types (new function). * config/aarch64/aarch64.md (spaceship<mode>4): Add define_expands for spaceship<mode>4 on integer and floating-point types. gcc/testsuite/ChangeLog: PR target/117013 * g++.target/aarch64/spaceship_1.C: New test. * g++.target/aarch64/spaceship_2.C: New test. * g++.target/aarch64/spaceship_3.C: New test.