public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug regression/16456] New: PowerPC - redundant subtract involving pointer types
@ 2004-07-09 18:05 gcc-bugzilla at gcc dot gnu dot org
  2004-07-09 18:57 ` [Bug other/16456] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-07-09 18:05 UTC (permalink / raw)
  To: gcc-bugs

Description:
A non-optimal code sequence is illustrated.  Two subtract operations are
done where only one is necessary.  Duplicate using gcc 3.5 and command
line:

gcc -O3 -m64 -c test.c

Testcase:
char * ptr1;
char * ptr2;
int x;
long int y;

void foo ()
{
    x = ptr1 - ptr2;
    y = ptr1 - ptr2;
}

Assembly:
      ld 9,.LC0@toc(2)
      ld 11,.LC1@toc(2)
      ld 0,0(9)
      ld 10,0(11)
      ld 8,.LC3@toc(2)
      subf 11,10,0
      ld 9,.LC2@toc(2)
      subf 0,10,0  -- no need to do this subtract, just use the previous
result.
      std 11,0(8)
      stw 0,0(9)
      blr



-- 
           Summary: PowerPC - redundant subtract involving pointer types
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P1
         Component: regression
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: steinmtz at us dot ibm dot com
                CC: gcc-bugs at gcc dot gnu dot org,steinmtz at us dot ibm
                    dot com
 GCC build triplet: powerpc64-linux
  GCC host triplet: powerpc64-linux
GCC target triplet: powerpc64-linux


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


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

* [Bug other/16456] PowerPC - redundant subtract involving pointer types
  2004-07-09 18:05 [Bug regression/16456] New: PowerPC - redundant subtract involving pointer types gcc-bugzilla at gcc dot gnu dot org
@ 2004-07-09 18:57 ` pinskia at gcc dot gnu dot org
  2004-07-09 19:15 ` [Bug rtl-optimization/16456] " pinskia at gcc dot gnu dot org
  2004-11-03 11:20 ` nathan at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-09 18:57 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|regression                  |other
           Keywords|                            |missed-optimization


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


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

* [Bug rtl-optimization/16456] PowerPC - redundant subtract involving pointer types
  2004-07-09 18:05 [Bug regression/16456] New: PowerPC - redundant subtract involving pointer types gcc-bugzilla at gcc dot gnu dot org
  2004-07-09 18:57 ` [Bug other/16456] " pinskia at gcc dot gnu dot org
@ 2004-07-09 19:15 ` pinskia at gcc dot gnu dot org
  2004-11-03 11:20 ` nathan at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-09 19:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-09 19:15 -------
Confirmed, the problem is they are different modes.
(set (reg:SI 124)
        (minus:SI (subreg:SI (reg:DI 119 [ ptr1.1 ]) 4)
            (subreg:SI (reg:DI 120 [ ptr2.4 ]) 4)))

(set (reg:DI 126)
        (minus:DI (reg:DI 119 [ ptr1.1 ])
            (reg:DI 120 [ ptr2.4 ])))

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|other                       |rtl-optimization
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-09 19:15:24
               date|                            |


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


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

* [Bug rtl-optimization/16456] PowerPC - redundant subtract involving pointer types
  2004-07-09 18:05 [Bug regression/16456] New: PowerPC - redundant subtract involving pointer types gcc-bugzilla at gcc dot gnu dot org
  2004-07-09 18:57 ` [Bug other/16456] " pinskia at gcc dot gnu dot org
  2004-07-09 19:15 ` [Bug rtl-optimization/16456] " pinskia at gcc dot gnu dot org
@ 2004-11-03 11:20 ` nathan at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: nathan at gcc dot gnu dot org @ 2004-11-03 11:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2004-11-03 11:20 -------
What is happening is that convert_to_integer, which is used to convert the
subtraction result to the type of 'x', reassociates the cast from
  (int)((long)ptr1 - (long)ptr2)
to
  (int)ptr1 - (int)ptr2
As it thinks that's a win.  Unfortunately this stops CSE noticing that
the later subtraction is actually the same.

This is another example of premature tree optimization, and it should be addressed
in the reworking of fold itself.  I don't think this should be attempted at stage 3

-- 


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


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

end of thread, other threads:[~2004-11-03 11:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-09 18:05 [Bug regression/16456] New: PowerPC - redundant subtract involving pointer types gcc-bugzilla at gcc dot gnu dot org
2004-07-09 18:57 ` [Bug other/16456] " pinskia at gcc dot gnu dot org
2004-07-09 19:15 ` [Bug rtl-optimization/16456] " pinskia at gcc dot gnu dot org
2004-11-03 11:20 ` nathan 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).