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] PR33600, fallout from pr33552 fix


On Mon, Oct 01, 2007 at 04:50:59AM +0200, Michael Matz wrote:
> a thinko caused this.  Funny that it didn't trigger on any of the four 
> test platforms, but on a kernel compile :-/
> 
> Will checkin when bootstrap and regtesting succeeds on i686.

This isn't sufficient.  The optimization already in the checking phase
should bail out if there is another matching constraint pair, which uses
the same REG as we want to change.
If we have:
(insn:HI 6 3 11 2 D.c:9 (parallel [
            (set (reg/v:SI 60 [ n ])
                (asm_operands:SI ("") ("=&a") 0 [
                        (reg/v:SI 60 [ n ])
                        (reg/v:SI 60 [ n ])
                    ]
                     [
                        (asm_input:SI ("1") ("") 0)
                        (asm_input:SI ("0") ("") 0)
                    ] ("D.c") 9))
            (set (reg/v:SI 58 [ x ])
                (asm_operands:SI ("") ("=r") 1 [
                        (reg/v:SI 60 [ n ])
                        (reg/v:SI 60 [ n ])
                    ]
                     [
                        (asm_input:SI ("1") ("") 0)
                        (asm_input:SI ("0") ("") 0)
                    ] ("D.c") 9))
            (clobber (reg:QI 18 fpsr))
            (clobber (reg:QI 17 flags))
        ]) -1 (expr_list:REG_UNUSED (reg/v:SI 58 [ x ])
        (expr_list:REG_UNUSED (reg:QI 18 fpsr)
            (expr_list:REG_UNUSED (reg:QI 17 flags)
                (nil)))))
then we don't want to replace all "n" inputs to "x", because it
really is not an optimization - while it improves the situation
for one pair, it pessimizes the other pair.
Now, unlike the extremely simplistic checking this optimization
does, to find if there is another pair would need to be exact checking,
i.e. parsing all the constraints.
A far simpler option would be just to bail out if there is another
dest REG with REGNO of input.  I.e. add:
	/* Check if replacing input with output doesn't pessimize
	   another matching constraint pair.  */
	if (REG_P (input))
	  {
	    for (j = 0; j < noutputs; j++)
	      if (REG_P (SET_DEST (p_sets[j]))
		  && reg_overlap_mentioned_p (input, SET_DEST (p_sets[j])))
	        break;
	    if (j < noutputs)
	      continue;
	  }
to the checking phase.

> 	PR inline-asm/33600
> 	* function.c (match_asm_constraints_1): Check for input
> 	being used in the outputs.
> 
> Index: gcc/function.c
> ===================================================================
> --- gcc/function.c	(Revision 128890)
> +++ gcc/function.c	(Arbeitskopie)
> @@ -5716,7 +5716,7 @@ match_asm_constraints_1 (rtx insn, rtx *
>  	 which wouldn't have happen without this pass.  So, iterate over
>  	 all operands and replace all occurences of the register used.  */
>        for (j = 0; j < noutputs; j++)
> -	if (!rtx_equal_p (SET_DEST (p_sets[j]), output)
> +	if (!rtx_equal_p (SET_DEST (p_sets[j]), input)
>  	    && reg_overlap_mentioned_p (input, SET_DEST (p_sets[j])))
>  	  SET_DEST (p_sets[j]) = replace_rtx (SET_DEST (p_sets[j]),
>  					      input, output);

	Jakub


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