public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/19126] New: Missed IV optimization (redundant instruction in loop)
@ 2004-12-22  5:08 pinskia at gcc dot gnu dot org
  2004-12-28 23:54 ` [Bug tree-optimization/19126] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-22  5:08 UTC (permalink / raw)
  To: gcc-bugs

Take the following two functions, they should produce the same asm, the second is better on powerpc 
at least for the inner loop (6 instructions vs 8):
void daxpy(int n, float  da, float  dx[], int incx, float  dy[], int incy)
{
  int i,ix=0,iy=0,m,mp1;
  
  mp1 = 0;
  m = 0;
  for (i = 0;i < n; i++){
    dy[iy] = dy[iy] + dx[ix];
    ix = ix + incx;
    iy = iy + incy;
  }
}
void daxpy1(int n, float  da, float  dx[], int incx, float  dy[], int incy)
{
  int i,ix=0,iy=0,m,mp1;
  mp1 = 0;
  m = 0;
  for (i = 0;i < n; i++){
    *(float*)(((char*)dy)+iy) = *(float*)(((char*)dy)+iy) + *(float*)(((char*)dx)+ix);
    ix = ix + incx*4;
    iy = iy + incy*4;
  }
}

inner loop for the first one:
L4:
	slwi r2,r9,2
	slwi r0,r11,2
	lfsx f13,r5,r0
	add r11,r11,r6
	lfsx f0,r7,r2
	add r9,r9,r8
	fadds f0,f0,f13
	stfsx f0,r7,r2
	bdnz L4

the second one:
L11:
	lfsx f0,r7,r0
	lfsx f13,r5,r2
	add r2,r2,r6
	fadds f0,f0,f13
	stfsx f0,r7,r0
	add r0,r0,r8
	bdnz L11

Yes this shows up in real code.

-- 
           Summary: Missed IV optimization (redundant instruction in loop)
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc-darwin


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


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

end of thread, other threads:[~2005-05-01 13:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-22  5:08 [Bug tree-optimization/19126] New: Missed IV optimization (redundant instruction in loop) pinskia at gcc dot gnu dot org
2004-12-28 23:54 ` [Bug tree-optimization/19126] " pinskia at gcc dot gnu dot org
2005-01-23 16:03 ` steven at gcc dot gnu dot org
2005-03-01 18:09 ` pinskia at gcc dot gnu dot org
2005-04-09 20:45 ` pinskia at gcc dot gnu dot org
2005-04-10 23:20 ` pinskia at gcc dot gnu dot org
2005-04-19 10:00 ` giovannibajo at libero dot it
2005-05-01  8:08 ` cvs-commit at gcc dot gnu dot org
2005-05-01 13:46 ` 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).