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

Re: [PATCH] REG_EQUAL notes on floatlib comparison libcalls


Roger Sayle <roger@eyesopen.com> writes:

> Zack's recent clean-up of optab.c's prepare_float_lib_cmp reminded
> me of an optimization I've been meaning to add there for a while.
> For soft-float targets, we're currently unable to optimize floating
> point comparisons once the function has been lowered to RTL.  The
> problem is that such comparisons appear as anonymous libcall functions
> to the RTL optimizers, so even if both operands can be determined to be
> compile-time constants, GCC is still unable to optimize the comparison
> away.
>
> The solution is to annotate these libcalls with their semantics using
> REG_EQUAL notes, much like we now do with SQRT libcalls.  By placing
> a suitable REG_EQUAL on the REG_RETVAL instruction of the libcall
> sequence, we can describe the floatlib function's return value.  This
> is sufficient so that should the RTL optimizers propagate constant
> operands into the REG_EQUAL note, the note may be simplified to a
> constant value, and thereby eliminate the libcall.

Oh cool, I was just thinking that something like this should be done.

Richard's beaten me to the approval, but ...

> +
> +   result = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST_MAKE_BLOCK,
> + 				    word_mode, 2, x, mode, y, mode);
> +

I think that if you wrap this call in a start_sequence/end_sequence
pair, use LCT_CONST instead of LCT_CONST_MAKE_BLOCK, and then invoke
emit_libcall_block, you needn't muck around searching for the right
insn to attach the note to.  See the idiom used in
e.g. expand_complex_abs.  Could you determine whether that works and
if so submit a followup patch?

zw


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