public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "luoxhu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140
Date: Thu, 30 Jun 2022 02:21:43 +0000	[thread overview]
Message-ID: <bug-106126-4-0V2Ixd6ky6@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106126-4@http.gcc.gnu.org/bugzilla/>

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.

  parent reply	other threads:[~2022-06-30  2:21 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-106126-4-0V2Ixd6ky6@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).