Georg-Johann Lay <[email protected]> writes:

> This patch proceeds converting insns with explicit hard registers to
> hard-reg constraints, this time for FMUL, FMULS and FMULSU instructions
> resp. their libgcc calls when no MUL is supported.
>
> One question I have for Stefan:
> ===============================
>
> The patch handles two orthogonal cases:
>
> A) Operation is commutative (fmul, fmuls) or not (fmulsu).
>
> B) Core supports MUL (use fmul* instruction) or doesn't support
> MUL (generate transparent libgcc call).
>
> I have tried two approaches to model commutativity of the inputs
> in the libgcc case.  These are the constraint alternatives with
> hard-regs:
>
> 1) Using the "%" constraint modifier like:
>    "={r22}"  ;; output
>    "%{r24}"  ;; 1st input
>     "{r25}"  ;; 2nd input
>
> 2) Using two constraint alternatives like:
>    "={r22},{r22}"  ;; output
>     "{r24},{r25}"  ;; 1st input
>     "{r25},{r24}"  ;; 2nd input
>
> Neither of which is working, i.e. RA always picks the first alternative.
>
> Are there plans to implement this?
>
> If yes, then what way to go? Using "%" is much more natural IMHO, and it
> allows for a neat, compact and intuitive description.  I would retain
> the patch until the work is upstream, and then use the way as you
> recommend.
>
> If not, I would just remove any attempts that try to exploit commutative
> operations and add a respective comment.
>
> I have attached a test case fmul.c.
>
> $ avr-gcc fmul.c -S -Os -mmcu=avr4 # takes the MUL route.
> $ avr-gcc fmul.c -S -Os -mmcu=avr2 # takes the no-MUL route.
>
> It has this test case:
>
> uint16_t gun2 ()
> {
>   uint8_t a, b;
>   __asm (";; %0 %1" : "={r24}" (a), "={r25}" (b));
>   return fmul (b, a);
> }
>
> which in the avr2 no-MUL path swaps r24 and r25, even though the
> operands of fmul commute and the patch tries to cater for that:
>
> gun2:
> /* #APP */
>       ;; r24 r25      
> /* #NOAPP */
> ->    mov r18,r25      ;  20  [c=4 l=1]  movqi_insn/0
> ->    mov r25,r24      ;  21  [c=4 l=1]  movqi_insn/0
> ->    mov r24,r18      ;  22  [c=4 l=1]  movqi_insn/0
>       rcall __fmul     ;  23  [c=8 l=1]  *fmul.call/0
>       mov r24,r22      ;  29  [c=4 l=1]  movqi_insn/0
>       mov r25,r23      ;  30  [c=4 l=1]  movqi_insn/0
> /* epilogue start */
>       ret              ;  27  [c=0 l=1]  return
>
> For Denis:
> ==========
>
> The patch is for trunk.  Ok with the changes as from above?

Ok.

Denis.

Reply via email to