* [Bug tree-optimization/108783] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3)
2023-02-14 3:44 [Bug tree-optimization/108783] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3) asolokha at gmx dot com
@ 2023-02-14 7:13 ` rguenth at gcc dot gnu.org
2023-02-15 11:16 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-02-14 7:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108783
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |needs-bisection
Ever confirmed|0 |1
CC| |rguenth at gcc dot gnu.org
Target Milestone|--- |13.0
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-02-14
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
reassoc1 does
<bb 3> [local count: 966367643]:
# a_4(ab) = PHI <x_9(D)(2), a_5(ab)(4)>
+ _14 = a_4(ab) != 0;
foo (x_9(D), y_12(D));
goto <bb 5>; [99.96%]
@@ -36,8 +59,7 @@
<bb 5> [local count: 1073312329]:
_1 = y_12(D) != 0;
_2 = a_4(ab) != 0;
- _3 = _1 & _2;
- _10 = _2 & _3;
+ _10 = _14 & _1;
_15 = (int) _10;
return _15;
Confirmed. It also inserts a new use of a_4(ab) which we try to generally
avoid
(but in this specific case it shouldn't be a problem).
Not sure why reassoc expands _2 and re-emits the _14 definition here.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/108783] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3)
2023-02-14 3:44 [Bug tree-optimization/108783] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3) asolokha at gmx dot com
2023-02-14 7:13 ` [Bug tree-optimization/108783] " rguenth at gcc dot gnu.org
@ 2023-02-15 11:16 ` jakub at gcc dot gnu.org
2023-02-15 11:26 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-15 11:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108783
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Keywords|needs-bisection |
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
ICEs since r13-1754-g7a158a5776f5ca95a318 when the check has been added.
Anyway, looking just at dumps, reassoc1 does this since
r5-4662-gd5e254e19c59fcc49265dda
That commit looks unrelated, but it actually changes quite a lot the generated
IL for some reason already starting with ssa dump.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/108783] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3)
2023-02-14 3:44 [Bug tree-optimization/108783] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3) asolokha at gmx dot com
2023-02-14 7:13 ` [Bug tree-optimization/108783] " rguenth at gcc dot gnu.org
2023-02-15 11:16 ` jakub at gcc dot gnu.org
@ 2023-02-15 11:26 ` jakub at gcc dot gnu.org
2023-02-15 11:45 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-15 11:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108783
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Though, the optimization that does this has been added in
r0-99848-g844381e5bc6eb515df838279 for PR28685.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/108783] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3)
2023-02-14 3:44 [Bug tree-optimization/108783] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3) asolokha at gmx dot com
` (2 preceding siblings ...)
2023-02-15 11:26 ` jakub at gcc dot gnu.org
@ 2023-02-15 11:45 ` jakub at gcc dot gnu.org
2023-02-15 12:38 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-15 11:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108783
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54465
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54465&action=edit
gcc13-pr108783.patch
Untested fix.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/108783] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3)
2023-02-14 3:44 [Bug tree-optimization/108783] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3) asolokha at gmx dot com
` (3 preceding siblings ...)
2023-02-15 11:45 ` jakub at gcc dot gnu.org
@ 2023-02-15 12:38 ` jakub at gcc dot gnu.org
2023-02-16 9:42 ` cvs-commit at gcc dot gnu.org
2023-02-16 9:42 ` jakub at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-15 12:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108783
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #54465|0 |1
is obsolete| |
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54466
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54466&action=edit
gcc13-pr108783.patch
Better patch. In the original testcase, a && a can be simplified to a despite
being (ab), and generally, there is no need to build_and_add_sum if t is the
same comparison as curr->op.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/108783] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3)
2023-02-14 3:44 [Bug tree-optimization/108783] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3) asolokha at gmx dot com
` (4 preceding siblings ...)
2023-02-15 12:38 ` jakub at gcc dot gnu.org
@ 2023-02-16 9:42 ` cvs-commit at gcc dot gnu.org
2023-02-16 9:42 ` jakub at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-16 9:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108783
--- Comment #6 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:55db240d28d29aac90a2d2af3768283ba6288752
commit r13-6074-g55db240d28d29aac90a2d2af3768283ba6288752
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Feb 16 10:41:18 2023 +0100
reassoc: Fix up (ab) handling in eliminate_redundant_comparison [PR108783]
The following testcase ICEs because eliminate_redundant_comparison sees
redundant comparisons in &&/|| where the comparison has (ab) SSA_NAME,
maybe_fold_{and,or}_comparisons optimizes them into a single comparison
and build_and_add_sum emits a new comparison close to the definition
operands, which in this case is before a returns_twice call (which is
invalid). Generally reassoc just punts on (ab) SSA_NAMEs, declares them
non-reassociable etc., so the second half of this patch does that.
Though we can do better in this case; the function has special code
when maybe_fold_{and,or}_comparisons returns INTEGER_CST (false/true)
or when what it returns is the same as curr->op (the first of the
comparisons we are considering) - in that case we just remove the
second one and keep the first one. The reason it doesn't match is that
curr->op is a SSA_NAME whose SSA_NAME_DEF_STMT is checked to be a
comparison, in this case _42 = a_1(ab) != 0 and the other comparison
is also like that. maybe_fold_{and,or}_comparisons looks through the
definitions though and so returns a_1(ab) != 0 as tree.
So the first part of the patch checks whether that returned comparison
isn't the same as the curr->op comparison and if yes, it just overrides
t back to curr->op so that its SSA_NAME is reused. In that case we can
handle even (ab) in {,new}op{1,2} because we don't create a new comparison
of that, just keep using the existing one. And t can't be (ab) because
otherwise it wouldn't be considered a reassociable operand.
The (ab) checks are needed say when we have a_1(ab) == 42 || a_1(ab) > 42
kind of comparisons where maybe_fold_{and,or}_comparisons returns a new
comparison not existing in the IL yet.
2023-02-16 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/108783
* tree-ssa-reassoc.cc (eliminate_redundant_comparison): If lcode
is equal to TREE_CODE (t), op1 to newop1 and op2 to newop2, set
t to curr->op. Otherwise, punt if either newop1 or newop2 are
SSA_NAME_OCCURS_IN_ABNORMAL_PHI SSA_NAMEs.
* gcc.c-torture/compile/pr108783.c: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/108783] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3)
2023-02-14 3:44 [Bug tree-optimization/108783] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 3) asolokha at gmx dot com
` (5 preceding siblings ...)
2023-02-16 9:42 ` cvs-commit at gcc dot gnu.org
@ 2023-02-16 9:42 ` jakub at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-16 9:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108783
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 8+ messages in thread