]> git.ipfire.org Git - thirdparty/gcc.git/commit
arm: don't vectorize fmaxf() unless unsafe math opts are enabled
authorRichard Earnshaw <rearnsha@arm.com>
Wed, 26 Mar 2025 15:56:18 +0000 (15:56 +0000)
committerRichard Earnshaw <rearnsha@arm.com>
Thu, 27 Mar 2025 10:54:23 +0000 (10:54 +0000)
commitb631ff45f231db55b28b4c92cf1a1b46b3638ddd
tree2c17bdf98c74ae55cba6a1dc99e10ac830ffad16
parent271745bafafbf3316d01ceb6430d67b894129a4c
arm: don't vectorize fmaxf() unless unsafe math opts are enabled

This test has presumably been failing since vectorization was enabled
at -O2.  I suspect part of the reason this wasn't picked up sooner is
that the test is a hybrid execution/scan-assembler test and the
execution part requires appropriate hardware.

The problem is that we are vectorizing an expansion of fmaxf() when
the vector version of the instruction does not preserve denormal
values.  This means we should only apply this optimization when
-funsafe-math-optimizations is enabled.

This fix does a few things:

- Moves the expand pattern to vec-common.md.  Although I haven't changed
its behaviour (beyond fixing the bug), this should really be enabled for
MVE as well (but that will need to wait for gcc-16 since the MVE code
needs some additional changes first).
- Adds support for HF mode vectors.
- splits the test that was exposing the bug into two parts: an executable
test and a scan-assembler test.  The scan-assembler version is more
widely enabled, since it does not require a suitable executable environment.

gcc/ChangeLog:

* config/arm/neon.md (<fmaxmin><mode>3): Move pattern from here...
* config/arm/vec-common.md (<fmaxmin><mode>3): ... to here.  Convert
to define_expand and disable the pattern when denormal values might
get truncated to zero.  Iterate on VF to add V4HF and V8HF variants.

gcc/testsuite/ChangeLog:

* gcc.target/arm/fmaxmin.c: Move scan-assembler checks to ...
* gcc.target/arm/fmaxmin-2.c: ... here.  New test.
gcc/config/arm/neon.md
gcc/config/arm/vec-common.md
gcc/testsuite/gcc.target/arm/fmaxmin-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/fmaxmin.c