public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/23128] New: VRP fails for unsigned values
@ 2005-07-29  9:32 rmorganl at u dot washington dot edu
  2005-07-29 11:35 ` [Bug tree-optimization/23128] [4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: rmorganl at u dot washington dot edu @ 2005-07-29  9:32 UTC (permalink / raw)
  To: gcc-bugs

VRP miscompiles the following testcase at -O2 (on a machine with 32-bit ints):

#include <stdlib.h>

void test(unsigned int a, unsigned int b)
{
        if (a < 5)
                abort();
        if (b < 5)
                abort();
        if (a + b != 0)
                abort();
}

int main()
{
        unsigned int x = 0x80000000;
        test(x, x);
}


The t27.vrp dump shows why:

...
D.1824_3: [10, 0fffffffe]  EQUIVALENCES: { } (0 elements)
a_4: [5, +INF]  EQUIVALENCES: { a_1 } (1 elements)
b_5: [5, +INF]  EQUIVALENCES: { b_2 } (1 elements)

Folding predicate D.1824_3 != 0 to 1
...

VRP concludes that since a >= 5 and b >= 5, a + b >= 10. However, since unsigned
variables have wrapping semantics, this is incorrect. It then miscompiles test()
to include an unconditional abort.

-- 
           Summary: VRP fails for unsigned values
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rmorganl at u dot washington dot edu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


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


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

end of thread, other threads:[~2005-08-06  5:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-29  9:32 [Bug tree-optimization/23128] New: VRP fails for unsigned values rmorganl at u dot washington dot edu
2005-07-29 11:35 ` [Bug tree-optimization/23128] [4.1 Regression] " pinskia at gcc dot gnu dot org
2005-07-30 18:14 ` phython at gcc dot gnu dot org
2005-08-06  5:35 ` cvs-commit at gcc dot gnu dot org
2005-08-06  5:43 ` phython at gcc dot gnu dot org

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