* [Bug tree-optimization/96671] Failure to optimize a 3 xor+and pattern to xor+andnot
2020-08-18 7:44 [Bug tree-optimization/96671] New: Failure to optimize a 3 xor+and pattern to xor + andnot gabravier at gmail dot com
@ 2020-08-18 7:45 ` gabravier at gmail dot com
2020-08-18 13:21 ` gabravier at gmail dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: gabravier at gmail dot com @ 2020-08-18 7:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96671
Gabriel Ravier <gabravier at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Summary|Failure to optimize a 3 |Failure to optimize a 3
|xor+and pattern to xor + |xor+and pattern to
|andnot |xor+andnot
--- Comment #1 from Gabriel Ravier <gabravier at gmail dot com> ---
Oops, I accidentally pressed enter and filed this with no details. Here are the
details :
int f(int a, int b, int c)
{
return (a ^ b) & ((b ^ c) ^ a);
}
This can be optimized to `return (a ^ b) & ~c`. This transformation is done by
LLVM, but not by GCC.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96671] Failure to optimize a 3 xor+and pattern to xor+andnot
2020-08-18 7:44 [Bug tree-optimization/96671] New: Failure to optimize a 3 xor+and pattern to xor + andnot gabravier at gmail dot com
2020-08-18 7:45 ` [Bug tree-optimization/96671] Failure to optimize a 3 xor+and pattern to xor+andnot gabravier at gmail dot com
@ 2020-08-18 13:21 ` gabravier at gmail dot com
2020-08-25 10:44 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: gabravier at gmail dot com @ 2020-08-18 13:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96671
--- Comment #2 from Gabriel Ravier <gabravier at gmail dot com> ---
There is also a very similar pattern with this function :
int f(int a, int b, int c)
{
return (a ^ b) | ((b ^ c) ^ a);
}
Which can be optimized to `return (a ^ b) | c;`.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96671] Failure to optimize a 3 xor+and pattern to xor+andnot
2020-08-18 7:44 [Bug tree-optimization/96671] New: Failure to optimize a 3 xor+and pattern to xor + andnot gabravier at gmail dot com
2020-08-18 7:45 ` [Bug tree-optimization/96671] Failure to optimize a 3 xor+and pattern to xor+andnot gabravier at gmail dot com
2020-08-18 13:21 ` gabravier at gmail dot com
@ 2020-08-25 10:44 ` rguenth at gcc dot gnu.org
2020-11-18 19:31 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-08-25 10:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96671
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-08-25
Status|UNCONFIRMED |NEW
Keywords| |easyhack
Ever confirmed|0 |1
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96671] Failure to optimize a 3 xor+and pattern to xor+andnot
2020-08-18 7:44 [Bug tree-optimization/96671] New: Failure to optimize a 3 xor+and pattern to xor + andnot gabravier at gmail dot com
` (2 preceding siblings ...)
2020-08-25 10:44 ` rguenth at gcc dot gnu.org
@ 2020-11-18 19:31 ` cvs-commit at gcc dot gnu.org
2021-01-15 13:26 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-11-18 19:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96671
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jeff Law <law@gcc.gnu.org>:
https://gcc.gnu.org/g:f44e6091627372bd8fc4e72874a003643b021dca
commit r11-5146-gf44e6091627372bd8fc4e72874a003643b021dca
Author: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
Date: Wed Nov 18 14:29:49 2020 -0500
Optimize two patterns with three xors
gcc/
PR tree-optimization/96671
* match.pd (three xor patterns): New patterns.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96671] Failure to optimize a 3 xor+and pattern to xor+andnot
2020-08-18 7:44 [Bug tree-optimization/96671] New: Failure to optimize a 3 xor+and pattern to xor + andnot gabravier at gmail dot com
` (3 preceding siblings ...)
2020-11-18 19:31 ` cvs-commit at gcc dot gnu.org
@ 2021-01-15 13:26 ` jakub at gcc dot gnu.org
2021-01-15 13:48 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-15 13:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96671
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Has any testcase been committed for this?
Also, for the 2 xors, I don't think we have any canonicalization, so can't that
(b ^ c) ^ a
part e.g. in #c1 come in also in
(b ^ a) ^ c
and
(a ^ c) ^ b
forms (I know it uses :c and that handles
(c ^ b) ^ a
a ^ (b ^ c)
a ^ (c ^ b)
for the first one.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96671] Failure to optimize a 3 xor+and pattern to xor+andnot
2020-08-18 7:44 [Bug tree-optimization/96671] New: Failure to optimize a 3 xor+and pattern to xor + andnot gabravier at gmail dot com
` (4 preceding siblings ...)
2021-01-15 13:26 ` jakub at gcc dot gnu.org
@ 2021-01-15 13:48 ` jakub at gcc dot gnu.org
2021-01-15 18:28 ` cvs-commit at gcc dot gnu.org
2021-01-15 18:29 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-15 13:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96671
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 49973
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49973&action=edit
gcc11-pr96671.patch
Seems we handle all those cases, so I think we just should add a testcase and
close.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96671] Failure to optimize a 3 xor+and pattern to xor+andnot
2020-08-18 7:44 [Bug tree-optimization/96671] New: Failure to optimize a 3 xor+and pattern to xor + andnot gabravier at gmail dot com
` (5 preceding siblings ...)
2021-01-15 13:48 ` jakub at gcc dot gnu.org
@ 2021-01-15 18:28 ` cvs-commit at gcc dot gnu.org
2021-01-15 18:29 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-15 18:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96671
--- Comment #7 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:aaec739250b1b148f7db5aa86719fe76645efc06
commit r11-6731-gaaec739250b1b148f7db5aa86719fe76645efc06
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Jan 15 19:26:01 2021 +0100
testsuite: Add testcase coverage for already fixed [PR96671]
The fix for this PR didn't come with any test coverage, I've added
tests that make sure we optimize it no matter what order of the x ^ y ^ z
operands is used.
2021-01-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/96671
* gcc.dg/tree-ssa/pr96671-1.c: New test.
* gcc.dg/tree-ssa/pr96671-2.c: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/96671] Failure to optimize a 3 xor+and pattern to xor+andnot
2020-08-18 7:44 [Bug tree-optimization/96671] New: Failure to optimize a 3 xor+and pattern to xor + andnot gabravier at gmail dot com
` (6 preceding siblings ...)
2021-01-15 18:28 ` cvs-commit at gcc dot gnu.org
@ 2021-01-15 18:29 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-15 18:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96671
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread