public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/31605]  New: VRP eliminates a useful test due to overflow
@ 2007-04-17 13:49 drow at gcc dot gnu dot org
  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
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: drow at gcc dot gnu dot org @ 2007-04-17 13:49 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-04-24 22:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-17 13:49 [Bug tree-optimization/31605] New: VRP eliminates a useful test due to overflow drow at gcc dot gnu dot org
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

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).