This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix alpha and arm bootstrap failures
- From: Roger Sayle <roger at www dot eyesopen dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Richard Earnshaw <rearnsha at arm dot com>, Brad Lucier <lucier at math dot purdue dot edu>, <gcc-patches at gcc dot gnu dot org>, Kazu Hirata <kazu at cs dot umass dot edu>
- Date: Wed, 26 Feb 2003 23:24:11 -0700 (MST)
- Subject: Re: [PATCH] Fix alpha and arm bootstrap failures
On Wed, 26 Feb 2003, Richard Henderson wrote:
> On Wed, Feb 26, 2003 at 02:50:37PM -0700, Roger Sayle wrote:
> > But we handle const, pure, nothrow and malloc attributes on
> > arbitrary non-libcall functions just fine without having to use
> > REG_EQUAL notes.
> How's that? What other mechanism do we use to prove that
> two calls to foo are identical?
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.
For libcall functions, this is placed in the REG_EQUAL note of
the last instruction of the sequence that bears the REG_RETVAL
note. This is not necessarily the call insn.
> > We can also recover much of our ability to CSE/GCSE by using
> > perfectly valid REG_EQUAL notes, such as "REG_EQUAL (lt:DF (reg:DF 1)
> > (reg: DF 2))" rather than the current "REG_EQUAL (expr_list ((symbol_ref
> > "__ltfdf2") (expr_list (reg:DF 1)..."
> Except that lt:DF would evaluate to FLOAT_STORE_FLAG_VALUE and lt:SI
> would evaluate to STORE_FLAG_VALUE. Neither of which is what __ltfdf2
We could abuse (if_then_else (lt:DF ...)) such that we make the return
values from the libgcc functions explicit in the RTL. The should we
constant propagate "fabs" and "0.0" into the REG_EQUAL note, simplify_rtx
should be able to reduce the expression to the return value constant.
Once done, DCE should eliminate the actual pure/const call altogether,
However I now appreciate having scanned more of the source code that
the correct quick fix to Kazu's patch is something like:
if (note && !find_reg_note (insn, REG_RETVAL, NULL_RTX))
i.e. ignore REG_EQUAL notes on instructions that also have REG_RETVAL
notes. This seems to be a fairly common idiom.
However mid-term it would be nice to be able to use REG_EQUAL notes
on libcalls productively, by marking the libcall's call insn with
its' CALL_INSN_FUNCTION_USAGE. By unifying the libcall/non-libcall
notes, it should simplify the GCC code that looks at either field.