[Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types)

2022-08-11 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106243

--- Comment #4 from CVS Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:621f5362253f00b910686e8221e6756457f71e81

commit r13-2019-g621f5362253f00b910686e8221e6756457f71e81
Author: Jakub Jelinek 
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  

PR tree-optimization/106243
* gcc.dg/pr106243.c: Add -Wno-psabi to dg-options.
* gcc.dg/pr106243-1.c: Likewise.

[Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types)

2022-08-06 Thread roger at nextmovesoftware dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106243

Roger Sayle  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 CC||roger at nextmovesoftware dot 
com
 Status|NEW |RESOLVED
   Target Milestone|--- |13.0

--- Comment #3 from Roger Sayle  ---
This has now been fixed on mainline (for both scalar and vector types).  Thanks
Sam.

[Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types)

2022-08-04 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106243

--- Comment #2 from CVS Commits  ---
The trunk branch has been updated by Sam Feifer :

https://gcc.gnu.org/g:39579ba8de9d91eafcc4943259b154a9e66538f1

commit r13-1962-g39579ba8de9d91eafcc4943259b154a9e66538f1
Author: Sam Feifer 
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.

[Bug tree-optimization/106243] Failure to optimize (0 - x) & 1 on gimple level (including vector types)

2022-07-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106243

Andrew Pinski  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  ---
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))
])