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: expr.c: don't assume MUL for scaling pointers


On Wed, 2 Nov 2011, DJ Delorie wrote:
>
> GCC assumes the target has a multiply insn, but better code is
> generated using shifts if it doesn't (vs a libcall).  Found with the
> rl78-elf port.
>
> 	* expr.c (expand_expr_real_2): Don't try to emit a MUL-based
> 	expression if the target doesn't have a multiply pattern.  Fall
> 	back to shifts instead of using libgcc calls.

Wouldn't this stop targets that have a scaling "lea"-type
indexing pattern but no multiply insns from using those
patterns?

>
> Index: gcc/expr.c
> ===================================================================
> --- gcc/expr.c	(revision 180758)
> +++ gcc/expr.c	(working copy)
> @@ -8289,12 +8289,13 @@ expand_expr_real_2 (sepops ops, rtx targ
>  	}
>
>        /* Attempt to return something suitable for generating an
>  	 indexed address, for machines that support that.  */
>
>        if (modifier == EXPAND_SUM && mode == ptr_mode
> +	  && optab_handler (smul_optab, mode) != CODE_FOR_nothing
>  	  && host_integerp (treeop1, 0))
>  	{
>  	  tree exp1 = treeop1;
>
>  	  op0 = expand_expr (treeop0, subtarget, VOIDmode,
>  			     EXPAND_SUM);
>


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