public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "lingling.kong7 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/103723] New: Loop invariant motion pass failed to remove unused code from loop
Date: Wed, 15 Dec 2021 02:54:40 +0000	[thread overview]
Message-ID: <bug-103723-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 103723
           Summary: Loop invariant motion pass failed to remove unused
                    code from loop
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lingling.kong7 at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/b7x1s5Yrn

For this case, the instruction  `mov     ecx, eax` in bb `.L3` could remove
from loop body and could sink to '.L8' and '.L1'.


After ivopt pass the tree dump is:

uint32_t test (uint32_t buf_avail, 
const uint8_t * buf, const uint8_t * buf_back)
{
  sizetype ivtmp.7;
  uint32_t len_test;
  unsigned char _3;
  sizetype _4;
  unsigned char _6;
  sizetype _7;
  unsigned int _15;
  unsigned int _16;
  unsigned int _17;

  <bb 2> [local count: 114863530]:
  if (buf_avail_8(D) > 2)
    goto <bb 6>; [94.50%]
  else
    goto <bb 8>; [5.50%]

  <bb 8> [local count: 6317494]:
  goto <bb 5>; [100.00%]

  <bb 6> [local count: 108546036]: 
 _15 = buf_avail_8(D) + 4294967293;
  _7 = (sizetype) _15;
  _4 = _7 + 3;
  goto <bb 4>; [100.00%]

  <bb 3> [local count: 958878296]:
  _16 = (unsigned int) ivtmp.7_19;
  len_test_12 = _16 + 1;
  ivtmp.7_18 = ivtmp.7_19 + 1;
  if (ivtmp.7_18 != _4)
    goto <bb 7>; [94.50%]
  else
    goto <bb 9>; [5.50%]

  <bb 9> [local count: 52738306]:
  # len_test_21 = PHI <len_test_12(3)>
  goto <bb 5>; [100.00%]

  <bb 7> [local count: 906139990]:

  <bb 4> [local count: 1014686026]:
  # ivtmp.7_19 = PHI <ivtmp.7_18(7), 2(6)>
  _17 = (unsigned int) ivtmp.7_19;
  len_test_13 = _17;
  _3 = MEM[(const uint8_t *)buf_9(D) + ivtmp.7_19 * 1];
  _6 = MEM[(const uint8_t *)buf_back_11(D) + ivtmp.7_19 * 1];
  if (_3 == _6)
    goto <bb 3>; [94.50%]
  else
    goto <bb 10>; [5.50%]

  <bb 10> [local count: 55807731]:
  # len_test_20 = PHI <len_test_13(4)>

  <bb 5> [local count: 114863531]:
  # len_test_14 = PHI <len_test_21(9), len_test_20(10), 2(8)>
  return len_test_14;

}

len_test_13 is unused in loop body and could sink to bb 5.

             reply	other threads:[~2021-12-15  2:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15  2:54 lingling.kong7 at gmail dot com [this message]
2021-12-15 11:39 ` [Bug tree-optimization/103723] zero extend not moved out of the loop after IV-OPTS pinskia at gcc dot gnu.org
2021-12-15 11:45 ` pinskia at gcc dot gnu.org
2022-01-04 11:24 ` [Bug tree-optimization/103723] zero extend not sunk out of the loop after IV-OPTS in the sink pass rguenth 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-103723-4@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).