public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "drow at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/31605]  New: VRP eliminates a useful test due to overflow
Date: Tue, 17 Apr 2007 13:49:00 -0000	[thread overview]
Message-ID: <bug-31605-3264@http.gcc.gnu.org/bugzilla/> (raw)

Most floating point tests fail when GDB is built with GCC trunk for mips-linux.
 I assume it shows up on all targets.  The miscompiled function is
doublest.c:put_field.  Here is a reduced test case:

int put_field (unsigned int start, unsigned int len)
{
  int cur_bitshift = ((start + len) % 8) - 8;

  if (cur_bitshift > -8)
    not_removed ();
}

When compiled with -O2, the resulting assembly file does not include a call to
not_removed.  But in fact it should be called in seven out of eight cases. 
((start + len) % 8) is an unsigned int in [0, 7].  "((start + len) % 8) - 8" is
an unsigned int in [UINT_MAX - 8, UINT_MAX].  cur_bitshift is an int, which can
not represent UINT_MAX; this is an implementation defined conversion, and the
GCC manual says that the value is reduced modulo (UINT_MAX+1) until it fits in
the range of int.  So the defined result of the conversion is in [-8, -1].

But VRP says:

Value ranges after VRP:

start_1(D): VARYING
len_2(D): VARYING
D.1559_3: [0, +INF]  EQUIVALENCES: { } (0 elements)
D.1560_4: [0, 7]  EQUIVALENCES: { } (0 elements)
D.1561_5: [4294967288, +INF]  EQUIVALENCES: { } (0 elements)
cur_bitshift_6: [-INF(OVF), -2147483648]  EQUIVALENCES: { } (0 elements)


Folding predicate cur_bitshift_6 >= -7 to 0
Removing basic block 3
Merging blocks 2 and 4
put_field (start, len)
{
  int cur_bitshift;
  unsigned int D.1561;
  unsigned int D.1560;
  unsigned int D.1559;

<bb 2>:
  D.1559_3 = start_1(D) + len_2(D);
  D.1560_4 = D.1559_3 & 7;
  D.1561_5 = D.1560_4 + 4294967288;
  cur_bitshift_6 = (int) D.1561_5;
  return;

}


-- 
           Summary: VRP eliminates a useful test due to overflow
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drow at gcc dot gnu dot org
GCC target triplet: mips-linux-gnu


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


             reply	other threads:[~2007-04-17 13:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-17 13:49 drow at gcc dot gnu dot org [this message]
2007-04-17 14:15 ` [Bug tree-optimization/31605] [4.3 Regression] VRP eliminates a useful test due with conversion from unsigned int to int pinskia at gcc dot gnu dot org
2007-04-17 14:28 ` pinskia at gcc dot gnu dot org
2007-04-17 19:20 ` pinskia at gcc dot gnu dot org
2007-04-17 19:28 ` [Bug tree-optimization/31605] [4.2/4.3 " pinskia at gcc dot gnu dot org
2007-04-21  1:08 ` ian at airs dot com
2007-04-24 20:38 ` mmitchel at gcc dot gnu dot org
2007-04-24 22:24 ` ian at gcc dot gnu dot org
2007-04-24 22:26 ` ian at gcc dot gnu dot org
2007-04-24 22:28 ` ian at airs dot com

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-31605-3264@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).