public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/37102] [4.3/4.4 Regression] possible integer codegen bug
Date: Thu, 14 Aug 2008 10:04:00 -0000	[thread overview]
Message-ID: <20080814100243.16104.qmail@sourceware.org> (raw)
In-Reply-To: <bug-37102-12544@http.gcc.gnu.org/bugzilla/>



------- Comment #3 from jakub at gcc dot gnu dot org  2008-08-14 10:02 -------
Somewhat shorter:
extern void abort (void);

unsigned int a, b = 1, c;

void __attribute__ ((noinline))
foo (int x)
{
  if (x != 5)
    abort ();
}

int
main ()
{
  unsigned int d, e;
  for (d = 1; d < 5; d++)
    if (c)
      a = b;
  a = b;
  e = a << 1;
  if (e)
    e = (e << 1) ^ 1;
  foo (e);
  return 0;
}

At *.tailc looks sane to me.
<bb 2>:
  pretmp.35_15 = c;
  b.1_5 = b;
  a_lsm.48_4 = a;
  if (pretmp.35_15 != 0)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:

<bb 4>:
  # a_lsm.48_28 = PHI <b.1_5(3), a_lsm.48_4(2)>
  a = b.1_5;
  e_9 = b.1_5 << 1;
  if (e_9 != 0)
    goto <bb 5>;
  else
    goto <bb 6>;
so a_lsm.48_28 is either b or a, depending on whether c != 0 or not, and a = b.
Then copyrename4 decides to replace a = b.1_5; with a = a_lsm_48_5; and at
*.uncprop we have:
<bb 2>:
  pretmp.35_15 = c;
  a_lsm.48_5 = b;
  a_lsm.48_4 = a;
  if (pretmp.35_15 != 0)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:

<bb 4>:
  # a_lsm.48_28 = PHI <a_lsm.48_5(3), a_lsm.48_4(2)>
  a = a_lsm.48_5;
  e_9 = a_lsm.48_5 << 1;
  if (e_9 != 0)
    goto <bb 5>;
  else
    goto <bb 6>;
which looks correct too.  But *.optimized is already wrong:
<bb 2>:
  a_lsm.49 = b;
  a_lsm.48 = a;
  if (c != 0)
    goto <bb 3>;
  else
    goto <bb 7>;

<bb 7>:
  a_lsm.49 = a_lsm.48;
  goto <bb 4>;

<bb 3>:

<bb 4>:
  a = a_lsm.49;
  e = a_lsm.49 << 1;
  if (e != 0)
    goto <bb 5>;
  else
    goto <bb 8>;
While in *.uncprop a was set unconditionally to b, now it is sometimes b and
sometimes a.


-- 


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


  parent reply	other threads:[~2008-08-14 10:04 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-13  3:46 [Bug c/37102] New: " regehr at cs dot utah dot edu
2008-08-13  9:54 ` [Bug tree-optimization/37102] [4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
2008-08-13  9:55 ` rguenth at gcc dot gnu dot org
2008-08-14 10:04 ` jakub at gcc dot gnu dot org [this message]
2008-08-18 13:58 ` jsm28 at gcc dot gnu dot org
2008-08-26 13:39 ` cnstar9988 at gmail dot com
2008-08-27 22:13 ` jsm28 at gcc dot gnu dot org
2008-08-28 14:49 ` rguenth at gcc dot gnu dot org
2008-09-04 14:54 ` [Bug tree-optimization/37102] [4.3/4.4 Regression] out-of-SSA is broken rguenth at gcc dot gnu dot org
2008-09-04 16:10 ` amacleod at redhat dot com
2008-09-04 16:19 ` rguenth at gcc dot gnu dot org
2008-09-04 16:53 ` amacleod at redhat dot com
2008-09-15  1:04 ` lthode at mail dot unomaha dot edu
2008-09-17 14:26 ` rguenth at gcc dot gnu dot org
2008-09-17 14:35 ` amacleod at redhat dot com
2008-09-17 14:39 ` rguenth at gcc dot gnu dot org
2008-09-17 14:40 ` amacleod at redhat dot com
2008-09-17 14:49 ` amacleod at redhat dot com
2008-09-17 21:57 ` amacleod at redhat dot com
2008-09-18 14:01 ` amacleod at gcc dot gnu dot org
2008-09-18 20:06 ` [Bug tree-optimization/37102] [4.3 " amacleod at redhat dot com
2008-09-27 11:33 ` cnstar9988 at gmail dot com
2008-10-10  0:57 ` cnstar9988 at gmail dot com
2008-10-12 19:59 ` lthode at mail dot unomaha dot edu
2008-10-17 17:38 ` amacleod at gcc dot gnu dot org
2008-10-18 11:19 ` rguenth at gcc dot gnu dot 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=20080814100243.16104.qmail@sourceware.org \
    --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).