public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/26898]  New: Fold does not fold signed +- CST CMP signed +- CST
@ 2006-03-28 13:49 rguenth at gcc dot gnu dot org
  2006-03-28 13:59 ` [Bug middle-end/26898] " rguenth 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-03-28 13:49 UTC (permalink / raw)
  To: gcc-bugs

Fold at the moment does not fold comparisons involving signed variables with
a constant offset.  Like we get from number-of-iterations analysis for

int foo0(int i0, int i1)
{
  int i, j = 0;
  for (i=i0; i<=i1+1; ++i)
    ++j;
  return j;
}

where niter->may_be_zero ends up as i0 + 1 < i1 + 2 which can be folded
to i0 < i1 + 1 because signed overflow is undefined.

And I have a patch for this.


-- 
           Summary: Fold does not fold signed +- CST CMP signed +- CST
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
        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=26898


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

* [Bug middle-end/26898] Fold does not fold signed +- CST CMP signed +- CST
  2006-03-28 13:49 [Bug middle-end/26898] New: Fold does not fold signed +- CST CMP signed +- CST rguenth at gcc dot gnu dot org
@ 2006-03-28 13:59 ` rguenth at gcc dot gnu dot org
  2006-03-30 21:49 ` [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2 where CST1 == CST2 pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-03-28 13:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2006-03-28 13:59 -------
Testcase:

void foo0(int i0, int i1)
{
  if (!(i0 + 1 < i1 + 1 == i0 < i1))
    link_error ();
}


-- 


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


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

* [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2 where CST1 == CST2
  2006-03-28 13:49 [Bug middle-end/26898] New: Fold does not fold signed +- CST CMP signed +- CST rguenth at gcc dot gnu dot org
  2006-03-28 13:59 ` [Bug middle-end/26898] " rguenth at gcc dot gnu dot org
@ 2006-03-30 21:49 ` pinskia at gcc dot gnu dot org
  2006-03-30 22:12 ` [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2 rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-30 21:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-03-30 21:49 -------
Confirmed, only when CST1 == CST2 does this work based on:
http://gcc.gnu.org/ml/gcc-patches/2006-03/msg01746.html


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-03-30 21:49:44
               date|                            |
            Summary|Fold does not fold signed +-|Fold does not fold signed +
                   |CST CMP signed +- CST       |CST1 CMP signed + CST2 where
                   |                            |CST1 == CST2


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


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

* [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2
  2006-03-28 13:49 [Bug middle-end/26898] New: Fold does not fold signed +- CST CMP signed +- CST rguenth at gcc dot gnu dot org
  2006-03-28 13:59 ` [Bug middle-end/26898] " rguenth at gcc dot gnu dot org
  2006-03-30 21:49 ` [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2 where CST1 == CST2 pinskia at gcc dot gnu dot org
@ 2006-03-30 22:12 ` rguenth at gcc dot gnu dot org
  2006-04-05 13:47 ` 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 @ 2006-03-30 22:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2006-03-30 22:12 -------
It also works for combined CST < CST1 or CST2, i.e.

  a +- c1 CMP b +- c2 to a CMP b +- c3 where c3 < c2


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Fold does not fold signed + |Fold does not fold signed +
                   |CST1 CMP signed + CST2 where|CST1 CMP signed + CST2
                   |CST1 == CST2                |


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


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

* [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2
  2006-03-28 13:49 [Bug middle-end/26898] New: Fold does not fold signed +- CST CMP signed +- CST rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-03-30 22:12 ` [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2 rguenth at gcc dot gnu dot org
@ 2006-04-05 13:47 ` rguenth at gcc dot gnu dot org
  2006-04-05 13:50 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-04-05 13:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2006-04-05 13:47 -------
This is mine.  And I have a patch posted.


-- 

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|NEW                         |ASSIGNED
   Last reconfirmed|2006-03-30 21:49:44         |2006-04-05 13:47:01
               date|                            |


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


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

* [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2
  2006-03-28 13:49 [Bug middle-end/26898] New: Fold does not fold signed +- CST CMP signed +- CST rguenth at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-04-05 13:47 ` rguenth at gcc dot gnu dot org
@ 2006-04-05 13:50 ` patchapp at dberlin dot org
  2006-10-21 13:21 ` rguenth at gcc dot gnu dot org
  2006-10-21 13:21 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: patchapp at dberlin dot org @ 2006-04-05 13:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from patchapp at dberlin dot org  2006-04-05 13:50 -------
Subject: Bug number PR26898

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2006-04/msg00190.html


-- 


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


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

* [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2
  2006-03-28 13:49 [Bug middle-end/26898] New: Fold does not fold signed +- CST CMP signed +- CST rguenth at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-04-05 13:50 ` patchapp at dberlin dot org
@ 2006-10-21 13:21 ` rguenth at gcc dot gnu dot org
  2006-10-21 13:21 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-10-21 13:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2006-10-21 13:21 -------
Subject: Bug 26898

Author: rguenth
Date: Sat Oct 21 13:21:06 2006
New Revision: 117931

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117931
Log:
2006-10-21  Richard Guenther  <rguenther@suse.de>

        PR middle-end/26898
        * fold-const.c (fold_comparison): Fold signed comparisons
        of the form X +- C1 CMP Y +- C2.

        * gcc.dg/torture/pr26898-1.c: New testcase.
        * gcc.dg/torture/pr26898-2.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr26898-1.c
    trunk/gcc/testsuite/gcc.dg/torture/pr26898-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2
  2006-03-28 13:49 [Bug middle-end/26898] New: Fold does not fold signed +- CST CMP signed +- CST rguenth at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-10-21 13:21 ` rguenth at gcc dot gnu dot org
@ 2006-10-21 13:21 ` rguenth at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-10-21 13:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2006-10-21 13:21 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2006-10-21 13:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-28 13:49 [Bug middle-end/26898] New: Fold does not fold signed +- CST CMP signed +- CST rguenth at gcc dot gnu dot org
2006-03-28 13:59 ` [Bug middle-end/26898] " rguenth at gcc dot gnu dot org
2006-03-30 21:49 ` [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2 where CST1 == CST2 pinskia at gcc dot gnu dot org
2006-03-30 22:12 ` [Bug middle-end/26898] Fold does not fold signed + CST1 CMP signed + CST2 rguenth at gcc dot gnu dot org
2006-04-05 13:47 ` rguenth at gcc dot gnu dot org
2006-04-05 13:50 ` patchapp at dberlin dot org
2006-10-21 13:21 ` rguenth at gcc dot gnu dot org
2006-10-21 13:21 ` rguenth 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).