This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug report, GCC 3.0.2/Pentium; PATCH included




GCC version: 3.0.2
Platform: Linux 2.2.19/glibc-2.1.3 on Pentium CPU
Configure opts: --prefix=/usr

Problem description:

The attached file "testcase.c" generates invalid assembly
code (EBP register used as base before it is set) when
compiled with "-O -fgcse -frerun-cse-after-loop -fomit-frame-pointer".

This problem has been previously reported (by me) against
3.0.1, but still exists in 3.0.2.

Optimization levels of O2 or higher with "-fomit-frame-pointer"
also manifest the problem.  I believe this same problem also
prevented a bootstrap of GCC with "-O3 -fomit-frame-pointer"
under 3.0.1; I have not tried the same experiment under 3.0.2.

The attached file "fofp_bug_patch" gives a one-line fix to
reload1.c that appears to fix the problem completely.  The
"testcase.c" file appears to generate correct assembly code,
and I have verified that a GCC bootstrap with "-O4 -fomit-frame-pointer"
works after applying the patch.

I'm not sure I can defend why the patch works; perhaps someone
more familiar with reload1.c can do that, or come up with a
better patch.  The problem seems to arise when the argp->esp
register elimination is marked "can't eliminate" because 
"elimination_effects()" thinks that argp has been used outside
of a "mem" context (why?).  I traced this to argp failing the
"CONSTANT_P" test (why?); replacing the CONSTANT_P with
"function_invariant_p" keeps the argp->esp elimination alive.

Regards,

Brad Kaiser
(bkaiser@acelink.net)

/*
 * Copyright (C) 1996-2000 Michael R. Elkins <me@cs.hmc.edu>
 * 
 *     This program is free software; you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation; either version 2 of the License, or
 *     (at your option) any later version.
 * 
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License
 *     along with this program; if not, write to the Free Software
 *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 */ 


#define FILE struct iobuf_
#define NULL  ((void *)0)
#define LONG_STRING 1024


extern int COLS;


void format_line (FILE *f, int ismacro,
			 const char *t1, const char *t2, const char *t3)
{
  int col;
  int col_a, col_b;
  int split;

  fputs (t1, f);

  /* don't try to press string into one line with less than 40 characters.
     The double paranthesis avoid a gcc warning, sigh ... */
  if ((split = COLS < 40))
  {
    col_a = col = 0;
    col_b = LONG_STRING;
    fputc ('\n', f);
  }
  else
  {
    col_a = COLS > 83 ? (COLS - 32) >> 2 : 12;
    col_b = COLS > 49 ? (COLS - 10) >> 1 : 19;
    col = pad (f, mutt_strlen(t1), col_a);
  }

  if (ismacro > 0)
  {
    if (!split)
    {
      col += print_macro (f, col_b - col - 4, &t2);
    }
  }

  col += print_macro (f, col_b - col - 1, &t2);
  if (split)
    fputc ('\n', f);
  else
    col = pad (f, col, col_b);

}


*** gcc-3.0.2/gcc/reload1.c	Thu Nov  1 22:36:49 2001
--- gcc-3.0.2p1/gcc/reload1.c	Fri Nov  2 10:46:32 2001
*************** elimination_effects (x, mem_mode)
*** 2714,2720 ****
  	}
        else if (reg_renumber[regno] < 0 && reg_equiv_constant
  	       && reg_equiv_constant[regno]
! 	       && ! CONSTANT_P (reg_equiv_constant[regno]))
  	elimination_effects (reg_equiv_constant[regno], mem_mode);
        return;
  
--- 2714,2720 ----
  	}
        else if (reg_renumber[regno] < 0 && reg_equiv_constant
  	       && reg_equiv_constant[regno]
! 	       && ! function_invariant_p (reg_equiv_constant[regno]))
  	elimination_effects (reg_equiv_constant[regno], mem_mode);
        return;
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]