* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
@ 2023-09-16 19:55 ` pinskia at gcc dot gnu.org
2023-09-16 19:59 ` pinskia at gcc dot gnu.org
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-16 19:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
Andrew Pinski <pinskia at gcc dot gnu.org> 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 <pinskia at gcc dot gnu.org> ---
Must be something 32bit related ...
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
2023-09-16 19:55 ` [Bug tree-optimization/111435] " pinskia at gcc dot gnu.org
@ 2023-09-16 19:59 ` pinskia at gcc dot gnu.org
2023-09-16 20:08 ` pinskia at gcc dot gnu.org
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-16 19:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
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 .
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
2023-09-16 19:55 ` [Bug tree-optimization/111435] " pinskia at gcc dot gnu.org
2023-09-16 19:59 ` pinskia at gcc dot gnu.org
@ 2023-09-16 20:08 ` pinskia at gcc dot gnu.org
2023-09-16 21:37 ` slyfox at gcc dot gnu.org
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-16 20:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
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))))
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (2 preceding siblings ...)
2023-09-16 20:08 ` pinskia at gcc dot gnu.org
@ 2023-09-16 21:37 ` slyfox at gcc dot gnu.org
2023-09-16 21:47 ` pinskia at gcc dot gnu.org
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: slyfox at gcc dot gnu.org @ 2023-09-16 21:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
--- Comment #4 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
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);
}
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (3 preceding siblings ...)
2023-09-16 21:37 ` slyfox at gcc dot gnu.org
@ 2023-09-16 21:47 ` pinskia at gcc dot gnu.org
2023-09-16 21:54 ` pinskia at gcc dot gnu.org
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-16 21:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is a better testcase:
```
void find_slot_with_hash(const int &,int, int);
void put(const int &k, const int &v) {
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);
}
```
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (4 preceding siblings ...)
2023-09-16 21:47 ` pinskia at gcc dot gnu.org
@ 2023-09-16 21:54 ` pinskia at gcc dot gnu.org
2023-09-16 22:28 ` pinskia at gcc dot gnu.org
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-16 21:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note my testcase needs exceptions turned on ...
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (5 preceding siblings ...)
2023-09-16 21:54 ` pinskia at gcc dot gnu.org
@ 2023-09-16 22:28 ` pinskia at gcc dot gnu.org
2023-09-17 1:45 ` pinskia at gcc dot gnu.org
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-16 22:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 55912
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55912&action=edit
Patch which I am testing
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (6 preceding siblings ...)
2023-09-16 22:28 ` pinskia at gcc dot gnu.org
@ 2023-09-17 1:45 ` pinskia at gcc dot gnu.org
2023-09-17 9:02 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-17 1:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
Andrew Pinski <pinskia at gcc dot gnu.org> 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 <pinskia at gcc dot gnu.org> ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/630668.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (7 preceding siblings ...)
2023-09-17 1:45 ` pinskia at gcc dot gnu.org
@ 2023-09-17 9:02 ` pinskia at gcc dot gnu.org
2023-09-17 10:50 ` slyfox at gcc dot gnu.org
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-17 9:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |zhendong.su at inf dot ethz.ch
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111442 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (8 preceding siblings ...)
2023-09-17 9:02 ` pinskia at gcc dot gnu.org
@ 2023-09-17 10:50 ` slyfox at gcc dot gnu.org
2023-09-17 16:06 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: slyfox at gcc dot gnu.org @ 2023-09-17 10:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
--- Comment #10 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
The proposed patch fixes my modified i686-linux gcc bootstrap as well. Thank
you!
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (9 preceding siblings ...)
2023-09-17 10:50 ` slyfox at gcc dot gnu.org
@ 2023-09-17 16:06 ` pinskia at gcc dot gnu.org
2023-09-18 8:33 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-17 16:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |shaohua.li at inf dot ethz.ch
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111443 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (10 preceding siblings ...)
2023-09-17 16:06 ` pinskia at gcc dot gnu.org
@ 2023-09-18 8:33 ` jakub at gcc dot gnu.org
2023-09-18 20:45 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-09-18 8:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
s/recusive/recursive/
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (11 preceding siblings ...)
2023-09-18 8:33 ` jakub at gcc dot gnu.org
@ 2023-09-18 20:45 ` cvs-commit at gcc dot gnu.org
2023-09-18 20:47 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-18 20:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:
https://gcc.gnu.org/g:951d3c191d01440ad54415f683437770b0c957e4
commit r14-4113-g951d3c191d01440ad54415f683437770b0c957e4
Author: Andrew Pinski <apinski@marvell.com>
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.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (12 preceding siblings ...)
2023-09-18 20:45 ` cvs-commit at gcc dot gnu.org
@ 2023-09-18 20:47 ` pinskia at gcc dot gnu.org
2023-09-19 0:15 ` pinskia at gcc dot gnu.org
2023-09-20 2:12 ` pinskia at gcc dot gnu.org
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-18 20:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #14 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #12)
> s/recusive/recursive/
Thanks I committed it with the spelling fix applied.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (13 preceding siblings ...)
2023-09-18 20:47 ` pinskia at gcc dot gnu.org
@ 2023-09-19 0:15 ` pinskia at gcc dot gnu.org
2023-09-20 2:12 ` pinskia at gcc dot gnu.org
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-19 0:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dcb314 at hotmail dot com
--- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111454 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug tree-optimization/111435] [14 Regression] gimple_zero_one_valued_p() infinite recursion
2023-09-16 19:54 [Bug tree-optimization/111435] New: [14 Regression] gimple_zero_one_valued_p() infinite recursion slyfox at gcc dot gnu.org
` (14 preceding siblings ...)
2023-09-19 0:15 ` pinskia at gcc dot gnu.org
@ 2023-09-20 2:12 ` pinskia at gcc dot gnu.org
15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-20 2:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111435
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |19373742 at buaa dot edu.cn
--- Comment #16 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111491 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 17+ messages in thread