public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ktietz at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/51783] New: Missed optimization for X ==/!= (signed type) ((unsigned type) Y + Z)
Date: Sat, 07 Jan 2012 12:09:00 -0000	[thread overview]
Message-ID: <bug-51783-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51783

             Bug #: 51783
           Summary: Missed optimization for X ==/!= (signed type)
                    ((unsigned type) Y + Z)
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ktietz@gcc.gnu.org
            Target: *-*-*


Hi,

for the following example shows the missed optimization

extern int ar[256];

int foo (int x, int y, unsigned int z)
{
  int c = (int) ((unsigned int) x + z);
  return y == c;
}

We produce in 4.7 for -O2 the following optimized gimple tree:

;; Function foo (foo, funcdef_no=0, decl_uid=1601, cgraph_uid=0)

foo (int x, int y, unsigned int z)
{
  int c;
  _Bool D.2717;
  int D.2716;
  unsigned int D.2715;
  unsigned int x.0;

<bb 2>:
  x.0_2 = (unsigned int) x_1(D);
  D.2715_4 = z_3(D) + x.0_2;
  c_5 = (int) D.2715_4;
  D.2717_7 = y_6(D) == c_5;
  D.2716_8 = (int) D.2717_7;
  return D.2716_8;

}

But we could expect in this case:

;; Function foo (foo, funcdef_no=0, decl_uid=1710, cgraph_uid=0)

foo (int x, int y, unsigned int z)
{
  int D.1720;
  int c;
  _Bool D.1717;
  int D.1716;

<bb 2>:
  D.1720_10 = (int) z_3(D);
  c_5 = x_1(D) + D.1720_10;
  D.1717_7 = y_6(D) == c_5;
  D.1716_8 = (int) D.1717_7;
  return D.1716_8;

}


             reply	other threads:[~2012-01-07 12:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-07 12:09 ktietz at gcc dot gnu.org [this message]
2012-01-07 18:25 ` [Bug tree-optimization/51783] " pinskia at gcc dot gnu.org
2012-01-07 18:55 ` ktietz at gcc dot gnu.org
2012-01-07 18:58 ` pinskia at gcc dot gnu.org
2012-01-07 19:04 ` ktietz at gcc dot gnu.org
2021-05-31  2: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-51783-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).