This is the mail archive of the gcc-help@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: clobber


Florent Defay <spira.inhabitant@gmail.com> writes:

> Here is a pattern used for shifting left. The function
> target_emit_shift directly outputs asm instructions.
> In this insn, operand 2 is used as a counter down to 0. Then after
> this insn operand 2's value is zero. So operand 2 is clobbered.
> That's why I use "clobber".
>
> (define_insn "*ashlsi3_2"
>   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "=r,m")
>                    (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
>                               (match_operand:HI 2 "register_operand" "r,r")))
>               (clobber (match_dup 2))])]
>   ""
>   {
>     return target_emit_shift(ASHLSI, operands);
>   })
>
> But it has no effect on GCC and operand 2 is used later just as if it
> was not clobbered. I think I do not use "clobber" properly.
> I did not find another way to do this. Please, could you tell me how
> to use "clobber" properly in this situation?

You shouldn't use clobber with match_dup because, as you have
discovered, it doesn't work.  Use clobber with other operands.

For this, I think it should work to use the + constraint to tell gcc
that the operand is both read and written.

Ian


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