]> git.ipfire.org Git - thirdparty/gcc.git/commit
vect: Make partial trapping ops use predication [PR96373]
authorRichard Sandiford <richard.sandiford@arm.com>
Mon, 3 Apr 2023 08:57:09 +0000 (09:57 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Mon, 3 Apr 2023 08:57:09 +0000 (09:57 +0100)
commite11513c7688f583d1f4d0961d79d8aa775add03d
treed8a281e5d6acd4e85ba6f2f8018fc89fc0c13b18
parenteff10fe7384d1504f2c92db1fd44c663f737f57d
vect: Make partial trapping ops use predication [PR96373]

PR96373 points out that a predicated SVE loop currently converts
trapping unconditional ops into unpredicated vector ops.  Doing
the operation on inactive lanes can then raise an exception.

As discussed in the PR trail, we aren't 100% consistent about
whether we preserve traps or not.  But the direction of travel
is clearly to improve that rather than live with it.  This patch
tries to do that for the SVE case.

Doing this regresses gcc.target/aarch64/sve/fabd_1.c.  I've added
-fno-trapping-math for now and filed PR108571 to track it.
A similar problem applies to fsubr_1.c.

I think this is likely to regress Power 10, since conditional
operations are only available for masked loops.  I think we'll
need to add -fno-trapping-math to any affected testcases,
but I don't have a Power 10 system to test on.

gcc/
PR tree-optimization/96373
PR tree-optimization/108979
* tree-vect-stmts.cc (vectorizable_operation): Predicate trapping
operations on the loop mask.  Reject partial vectors if this isn't
possible.  Don't mask operations on invariants.

gcc/testsuite/
PR tree-optimization/96373
PR tree-optimization/108571
PR tree-optimization/108979
* gcc.target/aarch64/sve/fabd_1.c: Add -fno-trapping-math.
* gcc.target/aarch64/sve/fsubr_1.c: Likewise.
* gcc.target/aarch64/sve/fmul_1.c: Expect predicate ops.
* gcc.target/aarch64/sve/fp_arith_1.c: Likewise.
* gfortran.dg/vect/pr108979.f90: New test.
gcc/testsuite/gcc.target/aarch64/sve/fabd_1.c
gcc/testsuite/gcc.target/aarch64/sve/fmul_1.c
gcc/testsuite/gcc.target/aarch64/sve/fp_arith_1.c
gcc/testsuite/gcc.target/aarch64/sve/fsubr_1.c
gcc/testsuite/gfortran.dg/vect/pr108979.f90 [new file with mode: 0644]
gcc/tree-vect-stmts.cc