public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/30317]  New: VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4
@ 2006-12-28 12:22 rguenth at gcc dot gnu dot org
  2006-12-28 16:03 ` [Bug tree-optimization/30317] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-12-28 12:22 UTC (permalink / raw)
  To: gcc-bugs

fold and VRP interact badly if we have a range test like

if (i > 0 && i <=5)
  ...

as we fold that to

if ((unsigned int) i + 0x0ffffffff > 4)
  ...

for which VRP fails to extract a range for i.  If we write the
range test so that fold doesn't see it, VRP is happy:

if (i > 0)
  if (i <= 5)
    ...


-- 
           Summary: VRP cannot extract a range from (unsigned int) i +
                    0x0ffffffff > 4
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


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

* [Bug tree-optimization/30317] VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4
  2006-12-28 12:22 [Bug tree-optimization/30317] New: VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4 rguenth at gcc dot gnu dot org
@ 2006-12-28 16:03 ` pinskia at gcc dot gnu dot org
  2007-01-20 13:45 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-12-28 16:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-12-28 16:03 -------
I think the range folding should late in compiling after VRP2 happens.  This
will also help out code that is written like:
if (i > 0)
  if (i <= 5)


-- 


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


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

* [Bug tree-optimization/30317] VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4
  2006-12-28 12:22 [Bug tree-optimization/30317] New: VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4 rguenth at gcc dot gnu dot org
  2006-12-28 16:03 ` [Bug tree-optimization/30317] " pinskia at gcc dot gnu dot org
@ 2007-01-20 13:45 ` rguenth at gcc dot gnu dot org
  2007-01-21 22:44 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-01-20 13:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2007-01-20 13:45 -------
I teached VRP to look for this idiom and during a C only bootstrap on i686 this
triggers 28921 times.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-01-20 13:45:05
               date|                            |


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


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

* [Bug tree-optimization/30317] VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4
  2006-12-28 12:22 [Bug tree-optimization/30317] New: VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4 rguenth at gcc dot gnu dot org
  2006-12-28 16:03 ` [Bug tree-optimization/30317] " pinskia at gcc dot gnu dot org
  2007-01-20 13:45 ` rguenth at gcc dot gnu dot org
@ 2007-01-21 22:44 ` rguenth at gcc dot gnu dot org
  2007-02-06 10:09 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-01-21 22:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2007-01-21 22:44 -------
Created an attachment (id=12929)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12929&action=view)
patch

This is what I currently have for this - it fails to bootstrap because it
miscompares.  A variant without the support for the anti-range tests

  if (a < 1 || a > 5)

aka

  if ((unsigned)a - 1 > 4)

bootstraps and tests ok, but the above adds useful things, so...

I guess the hunk in extract_range_from_assert may do the wrong thing
in some cases, but I didn't find a testcase for it.


-- 


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


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

* [Bug tree-optimization/30317] VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4
  2006-12-28 12:22 [Bug tree-optimization/30317] New: VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4 rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-01-21 22:44 ` rguenth at gcc dot gnu dot org
@ 2007-02-06 10:09 ` rguenth at gcc dot gnu dot org
  2008-03-28 12:21 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-02-06 10:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2007-02-06 10:08 -------
Created an attachment (id=13013)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13013&action=view)
alternate patch

This patch tackes the issue by allowing

  a_2 = ASSERT_EXRP <a_1, (unsigned)a_1 + 5 <= 10>

(and similar expressions).  A variant of this patch which had not undergone
a last-minute cosmetic cleanup survivied all-languages bootstrap and regtest
on x86_64-unknown-linux-gnu.


-- 


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


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

* [Bug tree-optimization/30317] VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4
  2006-12-28 12:22 [Bug tree-optimization/30317] New: VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4 rguenth at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-02-06 10:09 ` rguenth at gcc dot gnu dot org
@ 2008-03-28 12:21 ` rguenth at gcc dot gnu dot org
  2008-03-28 12:57 ` rguenth at gcc dot gnu dot org
  2009-09-26 18:22 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-03-28 12:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-03-28 12:21 -------
Subject: Bug 30317

Author: rguenth
Date: Fri Mar 28 12:20:09 2008
New Revision: 133680

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133680
Log:
2008-03-28  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/30317
        PR tree-optimization/30911
        PR tree-optimization/34793
        * tree-vrp.c (set_and_canonicalize_value_range): New function.
        (struct assert_locus_d): New member EXPR.
        (register_new_assert_for): Add EXPR parameter to support
        ASSERT_EXPR <name, expr OP limit>.
        (register_edge_assert_for_1): Adjust callers.
        (find_assert_locations): Likewise.
        (process_assert_insertions_for): Build condition from
        expression.
        (extract_range_from_assert): Handle ASSERT_EXPRs
        of the form ASSERT_EXPR <name, expr OP limit>.
        (register_edge_assert_for_2): New helper registering
        asserts for comparisons.  Recognize range tests of the form
        (unsigned)i - CST1 OP CST2.
        (register_edge_assert_for_1): Use it.
        (register_edge_assert_for): Likewise.
        * tree.def (ASSERT_EXPR): Document extra allowed conditional
        expressions.
        (needs_overflow_infinity): Integer sub-types
        do not need overflow infinities.
        (vrp_val_is_max): The extreme values of integer sub-types
        are those of the base type.
        (vrp_val_is_min): Likewise.

        * gcc.dg/tree-ssa/vrp35.c: New testcase.
        * gcc.dg/tree-ssa/vrp36.c: Likewise.
        * gcc.dg/tree-ssa/vrp37.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp35.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp36.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp37.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vrp.c
    trunk/gcc/tree.def


-- 


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


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

* [Bug tree-optimization/30317] VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4
  2006-12-28 12:22 [Bug tree-optimization/30317] New: VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4 rguenth at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-03-28 12:21 ` rguenth at gcc dot gnu dot org
@ 2008-03-28 12:57 ` rguenth at gcc dot gnu dot org
  2009-09-26 18:22 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-03-28 12:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2008-03-28 12:56 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to fail|                            |4.3.0
      Known to work|                            |4.4.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.4.0


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


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

* [Bug tree-optimization/30317] VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4
  2006-12-28 12:22 [Bug tree-optimization/30317] New: VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4 rguenth at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2008-03-28 12:57 ` rguenth at gcc dot gnu dot org
@ 2009-09-26 18:22 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-09-26 18:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2009-09-26 18:22 -------
*** Bug 41477 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arjan at linux dot intel dot
                   |                            |com


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


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

end of thread, other threads:[~2009-09-26 18:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-28 12:22 [Bug tree-optimization/30317] New: VRP cannot extract a range from (unsigned int) i + 0x0ffffffff > 4 rguenth at gcc dot gnu dot org
2006-12-28 16:03 ` [Bug tree-optimization/30317] " pinskia at gcc dot gnu dot org
2007-01-20 13:45 ` rguenth at gcc dot gnu dot org
2007-01-21 22:44 ` rguenth at gcc dot gnu dot org
2007-02-06 10:09 ` rguenth at gcc dot gnu dot org
2008-03-28 12:21 ` rguenth at gcc dot gnu dot org
2008-03-28 12:57 ` rguenth at gcc dot gnu dot org
2009-09-26 18:22 ` pinskia 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).