public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dizhao at os dot amperecomputing.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/101186] New: predictable comparison of integer variables not folded
Date: Thu, 24 Jun 2021 04:25:51 +0000	[thread overview]
Message-ID: <bug-101186-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 101186
           Summary: predictable comparison of integer variables not folded
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dizhao at os dot amperecomputing.com
  Target Milestone: ---

GCC fail to remove dead codes for following cases:

#include <stdio.h>

void f (unsigned int a, unsigned int b, unsigned int c)
// if a,b,c are signed, VRP can remove dead code
{
  if (a == b)
    {
      printf ("a");
      if (c < a)
        {
          printf ("b");
          if (c >= b)
            printf ("Unreachable!");
        }
    }
}

void g (int a, int b, int x, int y)
{
  int c = y;
  if (a != 0)
    c = x;
  while (b < 1000)
  // without this loop, jump thread & VRP can remove dead code
    {
      if (a != 0)
        {
          if (c > x)
            printf ("Unreachable!");
        }
      else
        printf ("a\n");
      b++;
    }
}

             reply	other threads:[~2021-06-24  4:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24  4:25 dizhao at os dot amperecomputing.com [this message]
2021-06-24  4:33 ` [Bug tree-optimization/101186] " pinskia at gcc dot gnu.org
2021-06-24  6:49 ` rguenth at gcc dot gnu.org
2021-06-24  6:50 ` rguenth at gcc dot gnu.org
2021-06-24  9:08 ` dizhao at os dot amperecomputing.com
2021-06-24 18:30 ` amacleod at redhat dot com
2021-06-27 15:30 ` aldyh at gcc dot gnu.org
2021-06-27 15:33 ` aldyh at gcc dot gnu.org
2021-06-28 19:20 ` law at gcc dot gnu.org
2021-07-19  6:35 ` pinskia 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-101186-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).