This is the mail archive of the 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]
Other format: [Raw text]

Re: [PATCH] Fix alpha and arm bootstrap failures

On Thu, 27 Feb 2003, Richard Henderson wrote:
> On Wed, Feb 26, 2003 at 11:24:11PM -0700, Roger Sayle wrote:
> > For non-libcall functions, the (use (mem:BLK (scratch))) used
> > to distinguish pure from const functions is maintained in the
> > CALL_INSN_FUNCTION_USAGE field of the CALL_INSN when the
> > CONST_OR_PURE_CALL_P bit is set.
> True, but irrelevant.  The _arguments_ are the relevant part
> to actually being able to CSE these functions.  Which are in

Yes, but there's no reason the expr_list for libcalls arguments
aren't also stored in the CALL_INSN_FUNCTION_USAGE the same way
as non-libcalls.  Using the REG_EQUAL note, means that this isn't
available to store REG_EQUAL information.

> Also wrong.  You'd miss folding __muldi3 when you find out
> that its arguments are constant.

And this is exactly why GCC currently fails to fold __muldi3 when
its arguments are constant!  The fact that the RTL optimizers can't
tell when a REG_EQUAL note on a libcall is a real REG_EQUAL note
from when its a list of arguments, means that most GCC routines
just punt.

For an easy to reproduce example under x86 Linux consider

double foo()
  double x = 2.0;
  double y = 3.0;
  return x * y;

and compare the "-O2 -S" output, with and without "-msoft-float".
You'll notice that we emit a libcall to __muldf3, even though
without it we evaluate the multiplication at compile time.

The question is whether we need to add special code to every
optimization pass that uses REG_EQUAL to determine whether
the libcall is using it for listing arguments as a special case,
or whether we list the arguments in libcalls the same way we do
for non-libcall arguments, so that REG_EQUAL notes always do
what they're supposed to.

I apologise for using this bug in GCC to push a point, but the
fact that we aren't constant folding libcalls is just the symptom,
the reason for our failure to optimize is the libcall abuse of
REG_EQUAL.  As I said before ignoring REG_EQUAL in the presence
of REG_RETVAL is a common idiom.  There's lots of code to fix.


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