[Bug tree-optimization/106900] Regression after memchr optimization

2023-05-18 Thread jbglaw--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106900

--- Comment #9 from Jan-Benedict Glaw  ---
All three target configurations reported a successful build. Thanks!

[Bug tree-optimization/106900] Regression after memchr optimization

2023-05-17 Thread jbglaw--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106900

--- Comment #8 from Jan-Benedict Glaw  ---
Thanks a lot!  I scheduled builds for the three affected targets (from my
target list.) The box is quite loaded right now (and a few jobs a before those
three), so I guess it'll take a few hours.

[Bug tree-optimization/106900] Regression after memchr optimization

2023-05-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106900

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |FIXED
   Target Milestone|--- |14.0
 Status|ASSIGNED|RESOLVED

--- Comment #7 from Andrew Pinski  ---
Fixed on the trunk; not really worth backporting since it is only an issue with
--enable-werror-always which almost nobody uses.

[Bug tree-optimization/106900] Regression after memchr optimization

2023-05-17 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106900

--- Comment #6 from CVS Commits  ---
The trunk branch has been updated by Andrew Pinski :

https://gcc.gnu.org/g:f65af1eeef670f2c249b1896726ef57bbf65fe2f

commit r14-937-gf65af1eeef670f2c249b1896726ef57bbf65fe2f
Author: Andrew Pinski 
Date:   Tue May 16 14:34:05 2023 -0700

Fix PR 106900: array-bounds warning inside simplify_builtin_call

The problem here is that VRP cannot figure out isize could not be 0
due to using integer_zerop. This patch removes the use of integer_zerop
and instead checks for 0 directly after converting the tree to
an unsigned HOST_WIDE_INT. This allows VRP to figure out isize is not 0
and `isize - 1` will always be >= 0.

This patch is just to avoid the warning that GCC could produce sometimes
and does not change any code generation or even VRP.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (simplify_builtin_call): Check
against 0 instead of calling integer_zerop.

[Bug tree-optimization/106900] Regression after memchr optimization

2023-05-16 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106900

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||patch
URL||https://gcc.gnu.org/piperma
   ||il/gcc-patches/2023-May/618
   ||762.html

--- Comment #5 from Andrew Pinski  ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618762.html

[Bug tree-optimization/106900] Regression after memchr optimization

2023-05-16 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106900

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |pinskia at gcc dot 
gnu.org
 Ever confirmed|0   |1
   Last reconfirmed||2023-05-16

--- Comment #4 from Andrew Pinski  ---
I am just going to test:
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index 06f19868ade..0326e6733e8 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -1231,14 +1231,14 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p,
tree callee2)
  tree size = gimple_call_arg (stmt2, 2);
  /* Size must be a constant which is <= UNITS_PER_WORD and
 <= the string length.  */
- if (TREE_CODE (size) != INTEGER_CST || integer_zerop (size))
+ if (TREE_CODE (size) != INTEGER_CST)
break;

  if (!tree_fits_uhwi_p (size))
break;

  unsigned HOST_WIDE_INT sz = tree_to_uhwi (size);
- if (sz > UNITS_PER_WORD || sz >= slen)
+ if (sz == 0 || sz > UNITS_PER_WORD || sz >= slen)
break;

  tree ch = gimple_call_arg (stmt2, 1);


This does not change the behavior of the code at all, just makes it obvious sz
cannot be 0 and therefore isize won't be 0 either.

[Bug tree-optimization/106900] Regression after memchr optimization

2023-02-25 Thread jbglaw--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106900

Jan-Benedict Glaw  changed:

   What|Removed |Added

 Target||avr-elf, pru-elf, rl78-elf

--- Comment #3 from Jan-Benedict Glaw  ---
Sure, just a warning, but still there (as of
31303c9b5bab200754cdb7ef8cd91ae4918f3018) and affecting three targets. Maybe we
get that understood/fixed?

[Bug tree-optimization/106900] Regression after memchr optimization

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

--- Comment #2 from Andrew Pinski  ---
Obviously this only happens because you use --enable-werror-always

[Bug tree-optimization/106900] Regression after memchr optimization

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

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||diagnostic

--- Comment #1 from Andrew Pinski  ---
Looks like gcc can't figure out that isize can't be 0 even if there was a check
for integer_zerop (size) before hand.
There must be a way to add an assert there to allow gcc to figure that out.