public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/106243] New: Failure to optimize (0 - x) & 1 on vector type
@ 2022-07-10 8:40 gabravier at gmail dot com
2022-07-10 20:29 ` [Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types) pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: gabravier at gmail dot com @ 2022-07-10 8:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106243
Bug ID: 106243
Summary: Failure to optimize (0 - x) & 1 on vector type
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
#include <stdint.h>
typedef int64_t v2i64 __attribute__((vector_size(16)));
v2i64 f(v2i64 x)
{
return (0 - x) & 1;
}
This can be optimized to `return x & 1;`. LLVM does this transformation, but
GCC does not
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types)
2022-07-10 8:40 [Bug tree-optimization/106243] New: Failure to optimize (0 - x) & 1 on vector type gabravier at gmail dot com
@ 2022-07-10 20:29 ` pinskia at gcc dot gnu.org
2022-08-04 13:37 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-10 20:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106243
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Failure to optimize (0 - x) |Failure to optimize (0 - x)
|& 1 on vector type |& 1 on gimple level
| |(including vector types)
Ever confirmed|0 |1
Last reconfirmed| |2022-07-10
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, even scalar version is not optimized on the gimple level:
int f1(int x)
{
x = -x;
return x & 1;
}
RTL level is done during combine for the scalar version:
Trying 6 -> 7:
6: {r86:SI=-r87:SI;clobber flags:CC;}
REG_DEAD r87:SI
REG_UNUSED flags:CC
7: {r85:SI=r86:SI&0x1;clobber flags:CC;}
REG_DEAD r86:SI
REG_UNUSED flags:CC
Successfully matched this instruction:
(parallel [
(set (reg:SI 85)
(and:SI (reg:SI 87)
(const_int 1 [0x1])))
(clobber (reg:CC 17 flags))
])
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types)
2022-07-10 8:40 [Bug tree-optimization/106243] New: Failure to optimize (0 - x) & 1 on vector type gabravier at gmail dot com
2022-07-10 20:29 ` [Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types) pinskia at gcc dot gnu.org
@ 2022-08-04 13:37 ` cvs-commit at gcc dot gnu.org
2022-08-06 21:41 ` roger at nextmovesoftware dot com
2022-08-11 8:29 ` cvs-commit at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-04 13:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106243
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Sam Feifer <sfeifer@gcc.gnu.org>:
https://gcc.gnu.org/g:39579ba8de9d91eafcc4943259b154a9e66538f1
commit r13-1962-g39579ba8de9d91eafcc4943259b154a9e66538f1
Author: Sam Feifer <sfeifer@redhat.com>
Date: Wed Aug 3 10:31:03 2022 -0400
match.pd: Add bitwise and pattern [PR106243]
This patch adds a new optimization to match.pd. The pattern, -x & 1,
now gets simplified to x & 1, reducing the number of instructions
produced.
This patch also adds tests for the optimization rule.
Bootstrapped/regtested on x86_64-pc-linux-gnu.
PR tree-optimization/106243
gcc/ChangeLog:
* match.pd (-x & 1): New simplification.
gcc/testsuite/ChangeLog:
* gcc.dg/pr106243-1.c: New test.
* gcc.dg/pr106243.c: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types)
2022-07-10 8:40 [Bug tree-optimization/106243] New: Failure to optimize (0 - x) & 1 on vector type gabravier at gmail dot com
2022-07-10 20:29 ` [Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types) pinskia at gcc dot gnu.org
2022-08-04 13:37 ` cvs-commit at gcc dot gnu.org
@ 2022-08-06 21:41 ` roger at nextmovesoftware dot com
2022-08-11 8:29 ` cvs-commit at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: roger at nextmovesoftware dot com @ 2022-08-06 21:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106243
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
CC| |roger at nextmovesoftware dot com
Status|NEW |RESOLVED
Target Milestone|--- |13.0
--- Comment #3 from Roger Sayle <roger at nextmovesoftware dot com> ---
This has now been fixed on mainline (for both scalar and vector types). Thanks
Sam.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types)
2022-07-10 8:40 [Bug tree-optimization/106243] New: Failure to optimize (0 - x) & 1 on vector type gabravier at gmail dot com
` (2 preceding siblings ...)
2022-08-06 21:41 ` roger at nextmovesoftware dot com
@ 2022-08-11 8:29 ` cvs-commit at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-11 8:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106243
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:621f5362253f00b910686e8221e6756457f71e81
commit r13-2019-g621f5362253f00b910686e8221e6756457f71e81
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Aug 11 10:29:06 2022 +0200
testsuite: Fix up pr106243* tests on i686-linux [PR106243]
These 2 tests were FAILing on i686-linux or e.g. with
--target_board=unix/-m32/-mno-sse on x86_64-linux due to
-Wpsabi warnings.
2022-08-11 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/106243
* gcc.dg/pr106243.c: Add -Wno-psabi to dg-options.
* gcc.dg/pr106243-1.c: Likewise.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-08-11 8:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-10 8:40 [Bug tree-optimization/106243] New: Failure to optimize (0 - x) & 1 on vector type gabravier at gmail dot com
2022-07-10 20:29 ` [Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types) pinskia at gcc dot gnu.org
2022-08-04 13:37 ` cvs-commit at gcc dot gnu.org
2022-08-06 21:41 ` roger at nextmovesoftware dot com
2022-08-11 8:29 ` 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).