[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

Andrew Pinski  changed:

   What|Removed |Added

 CC||19373742 at buaa dot edu.cn

--- Comment #16 from Andrew Pinski  ---
*** Bug 111491 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

Andrew Pinski  changed:

   What|Removed |Added

 CC||dcb314 at hotmail dot com

--- Comment #15 from Andrew Pinski  ---
*** Bug 111454 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

Andrew Pinski  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #14 from Andrew Pinski  ---
(In reply to Jakub Jelinek from comment #12)
> s/recusive/recursive/

Thanks I committed it with the spelling fix applied.

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

2023-09-18 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435

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

https://gcc.gnu.org/g:951d3c191d01440ad54415f683437770b0c957e4

commit r14-4113-g951d3c191d01440ad54415f683437770b0c957e4
Author: Andrew Pinski 
Date:   Sat Sep 16 15:19:58 2023 -0700

MATCH: Avoid recursive zero_one_valued_p for conversions

So when VN finds a name which has a nop conversion, it says
both names are equivalent to each other and the valuaization
function for one will return the other. This normally does not
cause any issues as there is no recursive matches. But after
r14-4038-gb975c0dc3be285, there was one added. So we would
do an infinite recursion on the match and never finish.
This fixes the issue (and adds a comment in match.pd) by
for converts just handle one level instead of being recursive
always.

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

Note the testcase was reduced from tree-ssa-loop-niter.cc and then
changed slightly into C rather than C++ but it still needs exceptions
turned on get the IR that VN would produce this equivalence relationship
going on. Also had to turn off early inline to force put to be inlined
later.

PR tree-optimization/111435

gcc/ChangeLog:

* match.pd (zero_one_valued_p): Don't do recursion
on converts.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr111435-1.c: New test.

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

2023-09-18 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #12 from Jakub Jelinek  ---
s/recusive/recursive/

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

Andrew Pinski  changed:

   What|Removed |Added

 CC||shaohua.li at inf dot ethz.ch

--- Comment #11 from Andrew Pinski  ---
*** Bug 111443 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

2023-09-17 Thread slyfox at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435

--- Comment #10 from Sergei Trofimovich  ---
The proposed patch fixes my modified i686-linux gcc bootstrap as well. Thank
you!

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

Andrew Pinski  changed:

   What|Removed |Added

 CC||zhendong.su at inf dot ethz.ch

--- Comment #9 from Andrew Pinski  ---
*** Bug 111442 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||patch
URL||https://gcc.gnu.org/piperma
   ||il/gcc-patches/2023-Septemb
   ||er/630668.html

--- Comment #8 from Andrew Pinski  ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/630668.html

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

--- Comment #7 from Andrew Pinski  ---
Created attachment 55912
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55912=edit
Patch which I am testing

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

--- Comment #6 from Andrew Pinski  ---
Note my testcase needs exceptions turned on ...

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

--- Comment #5 from Andrew Pinski  ---
Here is a better testcase:
```
void find_slot_with_hash(const int &,int, int);
void put(const int , const int ) {
find_slot_with_hash(k, 0, 1);
__builtin_unreachable();
}
unsigned len();
int *address();
void h(int header, int **bounds) {
  if (!*bounds)
return;
  unsigned t = *bounds ? len() : 0;
  int queue_index = t;
  address()[(unsigned)queue_index] = 0;
  put(header, queue_index);
}
```

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

2023-09-16 Thread slyfox at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435

--- Comment #4 from Sergei Trofimovich  ---
Meanwhile cvise extracted this test:

// $ cat tree-ssa-loop-niter.cc.cc
int discover_iteration_bound_by_body_walk_queue_index, m_vec;
int *address();
unsigned length();
int deref(unsigned ix) {
  int __trans_tmp_1 = address()[ix];
  return __trans_tmp_1;
}
unsigned discover_iteration_bound_by_body_walk___trans_tmp_4;
void discover_iteration_bound_by_body_walk() {
  bool __trans_tmp_3 = m_vec;
  if (!__trans_tmp_3)
return;
  discover_iteration_bound_by_body_walk___trans_tmp_4 = m_vec ? length() : 0;
  discover_iteration_bound_by_body_walk_queue_index =
  discover_iteration_bound_by_body_walk___trans_tmp_4;
  for (;;)
deref(discover_iteration_bound_by_body_walk_queue_index);
}

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

--- Comment #3 from Andrew Pinski  ---
Changing the match pattern for conversions to non-recusive fixes the issue.

That is:
/* A conversion from an zero_one_valued_p is still a [0,1].
   This is useful when the range of a variable is not known */
/* Note this matches can't be recusive because of the way VN handles
   nop conversions being equivalent and then recusive between them. */
(match zero_one_valued_p
 (convert@0 @1)
 (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
  && (TYPE_UNSIGNED (TREE_TYPE (@1))
  || TYPE_PRECISION (TREE_TYPE (@1)) > 1)
  && wi::leu_p (tree_nonzero_bits (@1), 1

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

--- Comment #2 from Andrew Pinski  ---
So Basically you can't have a recusive match because of the way VN works ...
I should have figured that out when I was adding bitwise_inverted_equal_p .

[Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion

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

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
 Ever confirmed|0   |1
   Last reconfirmed||2023-09-16
   Keywords||build, ice-on-valid-code
   Assignee|unassigned at gcc dot gnu.org  |pinskia at gcc dot 
gnu.org
   Target Milestone|--- |14.0

--- Comment #1 from Andrew Pinski  ---
Must be something 32bit related ...