public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87
@ 2022-06-28 17:46 dcb314 at hotmail dot com
  2022-06-28 17:51 ` [Bug tree-optimization/106126] " dcb314 at hotmail dot com
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: dcb314 at hotmail dot com @ 2022-06-28 17:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

            Bug ID: 106126
           Summary: tree check fail in useless_type_conversion_p, at
                    gimple-expr.cc:87
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Created attachment 53218
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53218&action=edit
C source code

For the attached C code, with recent gcc trunk and compiler flag -O2, I get

$ ../results/bin/gcc -c -O2 bug822.c
during GIMPLE pass: iftoswitch
/home/dcb36/rpmbuild/BUILD/libsolv-0.7.20/src/conda.c: In function
‘pool_conda_matchspec’:
/home/dcb36/rpmbuild/BUILD/libsolv-0.7.20/src/conda.c:679:1: internal compiler
error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in
useless_type_conversion_p, at gimple-expr.cc:87
  679 | }
      | ^
0x10fcfba tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ../../trunk.git/gcc/tree.cc:8866
0x9ffd8c tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        ../../trunk.git/gcc/tree.h:3639
0x9ffd8c useless_type_conversion_p(tree_node*, tree_node*)
        ../../trunk.git/gcc/gimple-expr.cc:87

I will have my usual go at identifying a git hash range and reducing the code.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
@ 2022-06-28 17:51 ` dcb314 at hotmail dot com
  2022-06-28 17:59 ` dcb314 at hotmail dot com
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: dcb314 at hotmail dot com @ 2022-06-28 17:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #1 from David Binderman <dcb314 at hotmail dot com> ---
Problem first seems to occur sometime between git hash 713f2fd923442b1b
and 98b6e62cf5e7d477, a couple of days later.

cvise reduction running in other window.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
  2022-06-28 17:51 ` [Bug tree-optimization/106126] " dcb314 at hotmail dot com
@ 2022-06-28 17:59 ` dcb314 at hotmail dot com
  2022-06-28 20:06 ` dcb314 at hotmail dot com
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: dcb314 at hotmail dot com @ 2022-06-28 17:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #2 from David Binderman <dcb314 at hotmail dot com> ---
Reduced C code seems to be

char *var_1;
void pool_conda_matchspec() {
  for (; var_1 && *var_1 &&
         *var_1 != '<' && *var_1 != '>' &&
         *var_1 != '!' && *var_1 != '~';)
    if (*var_1 >= 'A' && *var_1 <= 'Z')
      *var_1 += 'A';
}

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
  2022-06-28 17:51 ` [Bug tree-optimization/106126] " dcb314 at hotmail dot com
  2022-06-28 17:59 ` dcb314 at hotmail dot com
@ 2022-06-28 20:06 ` dcb314 at hotmail dot com
  2022-06-28 20:46 ` dcb314 at hotmail dot com
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: dcb314 at hotmail dot com @ 2022-06-28 20:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #3 from David Binderman <dcb314 at hotmail dot com> ---
I am trying a git bisect. Trying git f1fcd6e3ad911945.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2022-06-28 20:06 ` dcb314 at hotmail dot com
@ 2022-06-28 20:46 ` dcb314 at hotmail dot com
  2022-06-28 21:33 ` dcb314 at hotmail dot com
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: dcb314 at hotmail dot com @ 2022-06-28 20:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #4 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to David Binderman from comment #3)
> I am trying a git bisect. Trying git f1fcd6e3ad911945.

Goes wrong with that. Trying 607118dfa47a1865.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2022-06-28 20:46 ` dcb314 at hotmail dot com
@ 2022-06-28 21:33 ` dcb314 at hotmail dot com
  2022-06-29  9:47 ` rguenth at gcc dot gnu.org
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: dcb314 at hotmail dot com @ 2022-06-28 21:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #5 from David Binderman <dcb314 at hotmail dot com> ---
Seems good. Current range appears to be [607118dfa47a1865, f1fcd6e3ad911945].

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (4 preceding siblings ...)
  2022-06-28 21:33 ` dcb314 at hotmail dot com
@ 2022-06-29  9:47 ` rguenth at gcc dot gnu.org
  2022-06-29 11:45 ` dcb314 at hotmail dot com
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-29  9:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
   Last reconfirmed|                            |2022-06-29
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |needs-bisection
     Ever confirmed|0                           |1

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
a released SSA name in the IL after if-to-switch

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (5 preceding siblings ...)
  2022-06-29  9:47 ` rguenth at gcc dot gnu.org
@ 2022-06-29 11:45 ` dcb314 at hotmail dot com
  2022-06-29 11:53 ` dcb314 at hotmail dot com
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: dcb314 at hotmail dot com @ 2022-06-29 11:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #7 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to David Binderman from comment #5)
> Seems good. Current range appears to be [607118dfa47a1865, f1fcd6e3ad911945].

Tried 57424087e82db140 and that looked bad, so current range is
[607118dfa47a1865, 57424087e82db140].

Trying 70454c50b4592fe6.

A hot candidate for troublesome patch is 57424087e82db140.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (6 preceding siblings ...)
  2022-06-29 11:45 ` dcb314 at hotmail dot com
@ 2022-06-29 11:53 ` dcb314 at hotmail dot com
  2022-06-29 11:59 ` [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140 marxin at gcc dot gnu.org
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: dcb314 at hotmail dot com @ 2022-06-29 11:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #8 from David Binderman <dcb314 at hotmail dot com> ---
I seem strangely unable to add email address xionghuluo@tencent.com to this
email,
for their opinion on this bug report.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (7 preceding siblings ...)
  2022-06-29 11:53 ` dcb314 at hotmail dot com
@ 2022-06-29 11:59 ` marxin at gcc dot gnu.org
  2022-06-29 12:00 ` marxin at gcc dot gnu.org
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-06-29 11:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|tree check fail in          |[12 Regression] tree check
                   |useless_type_conversion_p,  |fail in
                   |at gimple-expr.cc:87        |useless_type_conversion_p,
                   |                            |at gimple-expr.cc:87 since
                   |                            |r13-1184-g57424087e82db140
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
           Keywords|needs-bisection             |

--- Comment #9 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r13-1184-g57424087e82db140.
I'm going to take a look.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (8 preceding siblings ...)
  2022-06-29 11:59 ` [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140 marxin at gcc dot gnu.org
@ 2022-06-29 12:00 ` marxin at gcc dot gnu.org
  2022-06-30  2:21 ` luoxhu at gcc dot gnu.org
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-06-29 12:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #10 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to David Binderman from comment #8)
> I seem strangely unable to add email address xionghuluo@tencent.com to this
> email,
> for their opinion on this bug report.

Yeah, he hasn't registered a bugzilla account. I'm going to write him an email.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (9 preceding siblings ...)
  2022-06-29 12:00 ` marxin at gcc dot gnu.org
@ 2022-06-30  2:21 ` luoxhu at gcc dot gnu.org
  2022-06-30  2:37 ` luoxhu at gcc dot gnu.org
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: luoxhu at gcc dot gnu.org @ 2022-06-30  2:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #11 from luoxhu at gcc dot gnu.org ---
Sorry for breaking, my bugzilla account is luoxhu@gcc.gnu.org.

The patch seems reasonable to fold 65-90 ('A'-'Z') to switch statement, 

4,6c4,6
< ;; Canonical GIMPLE case clusters: 33 60 62 126
< ;; BT can be built: BT(values:3 comparisons:6 range:30 density: 20.00%):33-62
126
< pr106126.c:3:28: optimized: Condition chain with 4 BBs transformed into a
switch statement.
---
> ;; Canonical GIMPLE case clusters: 33 60 62 65-90 126
> ;; BT can be built: BT(values:3 comparisons:6 range:30 density: 20.00%):33-62 65-90 126
> pr106126.c:3:28: optimized: Condition chain with 5 BBs transformed into a switch statement.

...

96,97c108,109
<   <bb 8> :
<   switch (_13) <default: <L11> [INV], case 33: <L10> [INV], case 60: <L10>
[INV], case 62: <L10> [INV], case 126: <L10> [INV]>
---
>   <bb 7> :
>   switch (_13) <default: <L13> [INV], case 33: <L10> [INV], case 60: <L10> [INV], case 62: <L10> [INV], case 65 ... 90: <L14> [INV], case 126: <L10> [INV]>




complete pr106126.bad.c.046t.iftoswitch:

;; Function pool_conda_matchspec (pool_conda_matchspec, funcdef_no=0,
decl_uid=1979, cgraph_uid=1, symbol_order=1)

;; Canonical GIMPLE case clusters: 33 60 62 65-90 126
;; BT can be built: BT(values:3 comparisons:6 range:30 density: 20.00%):33-62
65-90 126

pr106126.c:3:28: optimized: Condition chain with 5 BBs transformed into a
switch statement.
Removing basic block 9
;; basic block 9, loop depth 2
;;  pred:
if (_13 != 62)
  goto <bb 10>; [INV]
else
  goto <bb 12>; [INV]
;;  succ:       10
;;              12


Removing basic block 10
;; basic block 10, loop depth 2
;;  pred:
if (_13 != 33)
  goto <bb 11>; [INV]
else
  goto <bb 12>; [INV]
;;  succ:       11
;;              12


Removing basic block 11
;; basic block 11, loop depth 2
;;  pred:
if (_13 != 126)
  goto <bb 3>; [INV]
else
  goto <bb 12>; [INV]
;;  succ:       3
;;              12


Removing basic block 3
;; basic block 3, loop depth 2
;;  pred:
_3 = (unsigned char) _13;
_4 = _3 + 191;
if (_4 <= 25)
  goto <bb 14>; [INV]
else
  goto <bb 13>; [INV]
;;  succ:       14
;;              13


Expanded into a new gimple STMT: switch (_13) <default: <L12> [INV], case 33:
<L10> [INV], case 60: <L10> [INV], case 62: <L10> [INV], case 65 ... 90: <L11>
[INV], case 126: <L10> [INV]>

Removing basic block 13
;; basic block 13, loop depth 2
;;  pred:
<L12>:
goto <bb 6>; [100.00%]
;;  succ:       6


Removing basic block 14
;; basic block 14, loop depth 1
;;  pred:
<L11>:
;;  succ:       4


fix_loop_structure: fixing up loops for function
void pool_conda_matchspec ()
{
  unsigned char _8;
  char _10;
  char * var_1.3_11;
  char _13;
  unsigned char _14;
  char * var_1.3_15;

  <bb 2> :
  goto <bb 4>; [INV]

  <bb 3> :
  # _14 = PHI <_3(7)>
  # var_1.3_15 = PHI <var_1.3_11(7)>
<L14>:
  _8 = _14 + 65;
  _10 = (char) _8;
  *var_1.3_15 = _10;

  <bb 4> :

  <bb 5> :
<L13>:
  var_1.3_11 = var_1;
  if (var_1.3_11 != 0B)
    goto <bb 6>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 6> :
  _13 = *var_1.3_11;
  if (_13 != 0)
    goto <bb 7>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 7> :
  switch (_13) <default: <L13> [INV], case 33: <L10> [INV], case 60: <L10>
[INV], case 62: <L10> [INV], case 65 ... 90: <L14> [INV], case 126: <L10>
[INV]>

  <bb 8> :
<L10>:
  return;
  _8 = _14 + 65;
  _10 = (char) _8;
  *var_1.3_15 = _10;

  <bb 4> :

  <bb 5> :
<L13>:
  var_1.3_11 = var_1;
  if (var_1.3_11 != 0B)
    goto <bb 6>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 6> :
  _13 = *var_1.3_11;
  if (_13 != 0)
    goto <bb 7>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 7> :
  switch (_13) <default: <L13> [INV], case 33: <L10> [INV], case 60: <L10>
[INV], case 62: <L10> [INV], case 65 ... 90: <L14> [INV], case 126: <L10>
[INV]>

  <bb 8> :
<L10>:
  return;

}


The problem is _3 is removed in basic block 3, but _14 is still using it.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (10 preceding siblings ...)
  2022-06-30  2:21 ` luoxhu at gcc dot gnu.org
@ 2022-06-30  2:37 ` luoxhu at gcc dot gnu.org
  2022-06-30  3:34 ` luoxhu at gcc dot gnu.org
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: luoxhu at gcc dot gnu.org @ 2022-06-30  2:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #12 from luoxhu at gcc dot gnu.org ---
conditions_in_bbs->is_empty doesn't mean that range is at the start of switch
condition:(, so couldn't assume to ignore the no_side_effect_bb check?

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (11 preceding siblings ...)
  2022-06-30  2:37 ` luoxhu at gcc dot gnu.org
@ 2022-06-30  3:34 ` luoxhu at gcc dot gnu.org
  2022-06-30 13:03 ` marxin at gcc dot gnu.org
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: luoxhu at gcc dot gnu.org @ 2022-06-30  3:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #13 from luoxhu at gcc dot gnu.org ---
Otherwise we need record first_bb when conditions_in_bbs->is_empty, then check
that in is_beneficial, ordered_remove the info entry if that bb is not the
first "if condition" with side_effect statement in it, the fix would be as
below, but I am not sure whether it is worth&correct way doing this to handle
both PR105740 and PR106126?


git diff
diff --git a/gcc/gimple-if-to-switch.cc b/gcc/gimple-if-to-switch.cc
index f7b0b02628b..44bb0228856 100644
--- a/gcc/gimple-if-to-switch.cc
+++ b/gcc/gimple-if-to-switch.cc
@@ -63,7 +63,7 @@ struct condition_info

   condition_info (gcond *cond): m_cond (cond), m_bb (gimple_bb (cond)),
     m_forwarder_bb (NULL), m_ranges (), m_true_edge (NULL), m_false_edge
(NULL),
-    m_true_edge_phi_mapping (), m_false_edge_phi_mapping ()
+    m_true_edge_phi_mapping (), m_false_edge_phi_mapping (), first_bb(false)
   {
     m_ranges.create (0);
   }
@@ -80,6 +80,7 @@ struct condition_info
   edge m_false_edge;
   mapping_vec m_true_edge_phi_mapping;
   mapping_vec m_false_edge_phi_mapping;
+  bool first_bb;
 };

 /* Recond PHI mapping for an original edge E and save these into vector VEC. 
*/
@@ -194,6 +195,16 @@ if_chain::is_beneficial ()
   auto_vec<cluster *> clusters;
   clusters.create (m_entries.length ());

+  for (unsigned i = 0; i < m_entries.length (); i++)
+    {
+      condition_info *info = m_entries[i];
+      if (info->first_bb && i != 0 && !no_side_effect_bb (info->m_bb))
+       {
+         m_entries.ordered_remove (i);
+         break;
+       }
+    }
+
   for (unsigned i = 0; i < m_entries.length (); i++)
     {
       condition_info *info = m_entries[i];
@@ -397,6 +408,8 @@ find_conditions (basic_block bb,
   tree_code code = gimple_cond_code (cond);

   condition_info *info = new condition_info (cond);
+  if (conditions_in_bbs->is_empty ())
+    info->first_bb = true;

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (12 preceding siblings ...)
  2022-06-30  3:34 ` luoxhu at gcc dot gnu.org
@ 2022-06-30 13:03 ` marxin at gcc dot gnu.org
  2022-06-30 19:52 ` dcb314 at hotmail dot com
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-06-30 13:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--- Comment #14 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to luoxhu from comment #13)
> Otherwise we need record first_bb when conditions_in_bbs->is_empty, then
> check that in is_beneficial, ordered_remove the info entry if that bb is not
> the first "if condition" with side_effect statement in it, the fix would be

No, we need to record if a BB has a side effect and allow only side effects for
a first BB in the main loop in pass_if_to_switch::execute. I'm testing a patch
candidate.

> as below, but I am not sure whether it is worth&correct way doing this to
> handle both PR105740 and PR106126?

Well, I replied in PR105740 where the problem is one needs to run the pass
later.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (13 preceding siblings ...)
  2022-06-30 13:03 ` marxin at gcc dot gnu.org
@ 2022-06-30 19:52 ` dcb314 at hotmail dot com
  2022-07-01  6:48 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: dcb314 at hotmail dot com @ 2022-06-30 19:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

David Binderman <dcb314 at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcb314 at hotmail dot com

--- Comment #15 from David Binderman <dcb314 at hotmail dot com> ---
Created attachment 53230
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53230&action=edit
gzipped C++ source code


Please find attached an additional C++ test case. -O3 required this time:

$ /home/dcb/gcc/results/bin/g++ -c -O3 q1.ii
during GIMPLE pass: iftoswitch
../src/common/uri.cpp: In member function ‘const char*
wxURI::ParseUserInfo(const char*)’:
../src/common/uri.cpp:1086:1: internal compiler error: Segmentation fault
0x10ba099 crash_signal(int)
        ../../trunk.git/gcc/toplev.cc:322
0x134244a gimple_nop_p(gimple const*)
        ../../trunk.git/gcc/gimple.h:6747
0x134244a verify_use(basic_block_def*, basic_block_def*, ssa_use_operand_t*,
gimple*, bool, bitmap_head*)
        ../../trunk.git/gcc/tree-ssa.cc:880

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (14 preceding siblings ...)
  2022-06-30 19:52 ` dcb314 at hotmail dot com
@ 2022-07-01  6:48 ` cvs-commit at gcc dot gnu.org
  2022-07-01  6:48 ` [Bug tree-optimization/106126] [13 " marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-01  6:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #16 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:618bac5b486832edd3f8eb3ada74740e389dfcb8

commit r13-1375-g618bac5b486832edd3f8eb3ada74740e389dfcb8
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Jun 30 15:00:17 2022 +0200

    if-to-switch: properly allow side effects only for first condition

    Properly allow side effects only for a first BB in a condition chain.

            PR tree-optimization/106126

    gcc/ChangeLog:

            * gimple-if-to-switch.cc (struct condition_info): Save
            has_side_effect.
            (find_conditions): Parse all BBs.
            (pass_if_to_switch::execute): Allow only side effects for first
            BB.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr106126.c: New test.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [13 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (15 preceding siblings ...)
  2022-07-01  6:48 ` cvs-commit at gcc dot gnu.org
@ 2022-07-01  6:48 ` marxin at gcc dot gnu.org
  2022-07-01  6:54 ` marxin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-01  6:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12 Regression] tree check  |[13 Regression] tree check
                   |fail in                     |fail in
                   |useless_type_conversion_p,  |useless_type_conversion_p,
                   |at gimple-expr.cc:87 since  |at gimple-expr.cc:87 since
                   |r13-1184-g57424087e82db140  |r13-1184-g57424087e82db140
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #17 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed now.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [13 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (16 preceding siblings ...)
  2022-07-01  6:48 ` [Bug tree-optimization/106126] [13 " marxin at gcc dot gnu.org
@ 2022-07-01  6:54 ` marxin at gcc dot gnu.org
  2022-07-01  7:16 ` dcb314 at hotmail dot com
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-01  6:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #18 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to David Binderman from comment #15)
> Created attachment 53230 [details]
> gzipped C++ source code
> 
> 
> Please find attached an additional C++ test case. -O3 required this time:
> 
> $ /home/dcb/gcc/results/bin/g++ -c -O3 q1.ii
> during GIMPLE pass: iftoswitch
> ../src/common/uri.cpp: In member function ‘const char*
> wxURI::ParseUserInfo(const char*)’:
> ../src/common/uri.cpp:1086:1: internal compiler error: Segmentation fault
> 0x10ba099 crash_signal(int)
> 	../../trunk.git/gcc/toplev.cc:322
> 0x134244a gimple_nop_p(gimple const*)
> 	../../trunk.git/gcc/gimple.h:6747
> 0x134244a verify_use(basic_block_def*, basic_block_def*, ssa_use_operand_t*,
> gimple*, bool, bitmap_head*)
> 	../../trunk.git/gcc/tree-ssa.cc:880

I've just verified the following test-case is resolved fine with the current
master.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [13 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (17 preceding siblings ...)
  2022-07-01  6:54 ` marxin at gcc dot gnu.org
@ 2022-07-01  7:16 ` dcb314 at hotmail dot com
  2022-07-01 17:48 ` dcb314 at hotmail dot com
  2022-07-04 11:33 ` marxin at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: dcb314 at hotmail dot com @ 2022-07-01  7:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #19 from David Binderman <dcb314 at hotmail dot com> ---
Created attachment 53232
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53232&action=edit
gzipped C++ source code

I have a third test case. I suspect it is a duplicate of #2, 
but could I ask you to confirm this, please ?

It is part of the same package as #2, wxWidgets.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [13 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (18 preceding siblings ...)
  2022-07-01  7:16 ` dcb314 at hotmail dot com
@ 2022-07-01 17:48 ` dcb314 at hotmail dot com
  2022-07-04 11:33 ` marxin at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: dcb314 at hotmail dot com @ 2022-07-01 17:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #20 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to David Binderman from comment #19)
> I have a third test case. I suspect it is a duplicate of #2, 
> but could I ask you to confirm this, please ?
> 
> It is part of the same package as #2, wxWidgets.

I checked here and all is in order.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug tree-optimization/106126] [13 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
  2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
                   ` (19 preceding siblings ...)
  2022-07-01 17:48 ` dcb314 at hotmail dot com
@ 2022-07-04 11:33 ` marxin at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-04 11:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106126

--- Comment #21 from Martin Liška <marxin at gcc dot gnu.org> ---
> I checked here and all is in order.

Great, thanks for testing.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2022-07-04 11:33 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28 17:46 [Bug c/106126] New: tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 dcb314 at hotmail dot com
2022-06-28 17:51 ` [Bug tree-optimization/106126] " dcb314 at hotmail dot com
2022-06-28 17:59 ` dcb314 at hotmail dot com
2022-06-28 20:06 ` dcb314 at hotmail dot com
2022-06-28 20:46 ` dcb314 at hotmail dot com
2022-06-28 21:33 ` dcb314 at hotmail dot com
2022-06-29  9:47 ` rguenth at gcc dot gnu.org
2022-06-29 11:45 ` dcb314 at hotmail dot com
2022-06-29 11:53 ` dcb314 at hotmail dot com
2022-06-29 11:59 ` [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140 marxin at gcc dot gnu.org
2022-06-29 12:00 ` marxin at gcc dot gnu.org
2022-06-30  2:21 ` luoxhu at gcc dot gnu.org
2022-06-30  2:37 ` luoxhu at gcc dot gnu.org
2022-06-30  3:34 ` luoxhu at gcc dot gnu.org
2022-06-30 13:03 ` marxin at gcc dot gnu.org
2022-06-30 19:52 ` dcb314 at hotmail dot com
2022-07-01  6:48 ` cvs-commit at gcc dot gnu.org
2022-07-01  6:48 ` [Bug tree-optimization/106126] [13 " marxin at gcc dot gnu.org
2022-07-01  6:54 ` marxin at gcc dot gnu.org
2022-07-01  7:16 ` dcb314 at hotmail dot com
2022-07-01 17:48 ` dcb314 at hotmail dot com
2022-07-04 11:33 ` marxin at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).