public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/108571] New: Fix for PR96373 regresses fabd_1.c with -ftrapping-math
@ 2023-01-27 10:42 rsandifo at gcc dot gnu.org
2023-02-14 9:18 ` [Bug tree-optimization/108571] " cvs-commit at gcc dot gnu.org
2023-04-03 8:58 ` cvs-commit at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2023-01-27 10:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108571
Bug ID: 108571
Summary: Fix for PR96373 regresses fabd_1.c with
-ftrapping-math
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: rsandifo at gcc dot gnu.org
Target Milestone: ---
Target: aarch64*-*-*
The upcoming fix for PR96373 means that, without -fno-trapping-math,
we can no longer optimise abs(a - b) to absolute-difference(a, b)
for predicated SVE loops. The subtraction becomes predicated,
and so we have the equivalent of:
abs(IFN_COND_SUB(loopmask, a, b, c))
where c is the fallback/else value. It isn't possible to tell from
this expression alone that the value of the abs result doesn't
matter for false loopmask elements (and that c will do just as
well as abs(c)). It therefore isn't possible to fold this into
a conditional absolute difference without further information.
One possible fix would be to add a gimple value and RTL object that
represents an unknown/undefined/don't-care value, a bit like LLVM's
undef. Another would be to make absolute difference a recognised
gimple operation (via ifns) and make the vectoriser produce it
directly. Or we could add a pass that back-propagates information
about uses to discover which elements of a vector actually matter
(which I think would also require gimple-level absolute difference).
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/108571] Fix for PR96373 regresses fabd_1.c with -ftrapping-math
2023-01-27 10:42 [Bug tree-optimization/108571] New: Fix for PR96373 regresses fabd_1.c with -ftrapping-math rsandifo at gcc dot gnu.org
@ 2023-02-14 9:18 ` cvs-commit at gcc dot gnu.org
2023-04-03 8:58 ` cvs-commit at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-14 9:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108571
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsandifo@gcc.gnu.org>:
https://gcc.gnu.org/g:b9c78605039f839f3c79ad8fca4f60ea9a5654ed
commit r13-5979-gb9c78605039f839f3c79ad8fca4f60ea9a5654ed
Author: Richard Sandiford <richard.sandiford@arm.com>
Date: Tue Feb 14 09:18:07 2023 +0000
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
* tree-vect-stmts.cc (vectorizable_operation): Predicate trapping
operations on the loop mask. Reject partial vectors if this isn't
possible.
gcc/testsuite/
PR tree-optimization/96373
PR tree-optimization/108571
* 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/108571] Fix for PR96373 regresses fabd_1.c with -ftrapping-math
2023-01-27 10:42 [Bug tree-optimization/108571] New: Fix for PR96373 regresses fabd_1.c with -ftrapping-math rsandifo at gcc dot gnu.org
2023-02-14 9:18 ` [Bug tree-optimization/108571] " cvs-commit at gcc dot gnu.org
@ 2023-04-03 8:58 ` cvs-commit at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-03 8:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108571
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Richard Sandiford
<rsandifo@gcc.gnu.org>:
https://gcc.gnu.org/g:e11513c7688f583d1f4d0961d79d8aa775add03d
commit r12-9384-ge11513c7688f583d1f4d0961d79d8aa775add03d
Author: Richard Sandiford <richard.sandiford@arm.com>
Date: Mon Apr 3 09:57:09 2023 +0100
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-03 8:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 10:42 [Bug tree-optimization/108571] New: Fix for PR96373 regresses fabd_1.c with -ftrapping-math rsandifo at gcc dot gnu.org
2023-02-14 9:18 ` [Bug tree-optimization/108571] " cvs-commit at gcc dot gnu.org
2023-04-03 8:58 ` cvs-commit at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).