https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212

--- Comment #308 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Kazumoto Kojima from comment #305)
> (In reply to Oleg Endo from comment #304)
> > I think this is a bit clearer, thanks!  One more question .... 
> > 
> > (define_insn "block_lump_real"
> >   [(set (mem:BLK (match_operand:SI 2 "sfunc_arg0_reg" "=r,r"))
> >        (mem:BLK (match_operand:SI 3 "sfunc_arg1_reg" "=r,r")))
> >    (use (match_operand:SI 0 "arith_reg_operand" "r,r"))
> >    (use (match_operand 1 "" "Z,Ccl"))
> >    (use (match_operand:SI 4 "sfunc_arg2_reg" "=r,r"))
> > 
> >    (use (reg:SI R4_REG))        <<<<<<
> >    (use (reg:SI R5_REG))        <<<<<<
> >    (use (reg:SI R6_REG))        <<<<<<
> > 
> >    (clobber (match_dup 2))
> >    (clobber (match_dup 3))
> >    (clobber (match_dup 4))
> >    (clobber (reg:SI PR_REG))
> > 
> > Is it possible to do '(use (match_dup 2)' and so on instead of having the
> > hard regs in there?
> 
> It isn't.  When replacing hard reg with match_dup, it compiles our tiny
> sfunc test to:
> 
> foo:
>       mov.l   r14,@-r15       ! 32    [c=4 l=2]  movsi_ie/8
>       mov     r4,r5   ! 23    [c=4 l=2]  movsi_ie/1
>       sts.l   pr,@-r15        ! 33    [c=4 l=2]  movsi_ie/10
>       mov.w   .L6,r1  ! 34    [c=10 l=2]  *movhi/0
>       mov     #0,r7   ! 16    [c=4 l=2]  movsi_ie/2
>       mov.l   .L4,r6  ! 29    [c=10 l=2]  movsi_ie/0
>       sub     r1,r15  ! 35    [c=4 l=2]  *subsi3_internal
>       mov     r15,r14 ! 30    [c=4 l=2]  movsi_ie/1
>       add     #4,r14  ! 31    [c=4 l=2]  *addsi3_compact_lra/0
>       jsr     @r6     ! 12    [c=1 l=2]  block_lump_real_i4/0
>       mov     r14,r4  ! 9     [c=4 l=2]  movsi_ie/1
>       ...
> .L6:
>       .short  260
> 
> which wrongly assigns r6 to the function address, for example.

Thanks for confirming it.  In this case, wouldn't it be better to explicitly
mention the hard reg numbers everywhere, where they are involved?  Otherwise
the definitions are bara-bara all over the place.  For example:

(define_insn "block_lump_real"
  [(set (mem:BLK (match_operand:SI 2 "hard_reg_r4" "=r,r"))
           (mem:BLK (match_operand:SI 3 "hard_reg_r5" "=r,r")))
   (use (match_operand:SI 0 "arith_reg_operand" "r,r"))
   (use (match_operand 1 "" "Z,Ccl"))
   (use (match_operand:SI 4 "hard_reg_r6" "=r,r"))
   (use (reg:SI R4_REG))
   (use (reg:SI R5_REG))
   (use (reg:SI R6_REG))
   (clobber (match_dup 2))
   (clobber (match_dup 3))
   (clobber (match_dup 4))
   (clobber (reg:SI PR_REG))


But actually, why are the register constraints "=r,r"?  The insn only takes
inputs, but those are declared as outputs.  That looks wrong to me.  Perhaps
that's why the need for the seemingly superflous (use (reg:SI ... )?

Reply via email to