extra instructions lost from -O0 to -O1

Thomas A.M. Bernard t.bernard@uva.nl
Thu Sep 11 14:28:00 GMT 2008


Steven,

In the MD file, I have this pattern:

(define_insn "setallocate"
    [(setallocate (match_operand:DI 0 "general_operand" "r")
    )]
  ""
  "allocate %0\t\t#TCB_INSTRUCTIONS" 
[(set_attr "type" "multi")])

As you said dce takes out the instruction when flag -01 is engaged. I 
would like to reformat the pattern with the proper side-effects to 
ensure that the instruction will stay whatever flag is used. Any clue in 
this example ? I have tried unspec_volatile without success though. As 
follow,

(define_insn "setallocate"
    [(setallocate
            (unspec_volatile:DI [ (match_operand:DI 0 "general_operand" 
"r")]
                                        UNSPEC_ALLOCATE)
    )]
  ""
  "allocate %0\t\t#TCB_INSTRUCTIONS" 
    [(set_attr "type" "multi")])

Thanks for any help.
Thomas
 
Steven Bosscher wrote:
> On Thu, Sep 11, 2008 at 10:38 AM, Thomas A.M. Bernard <t.bernard@uva.nl> wrote:
>   
>> Hi,
>>
>> I inserted some extra instructions in the Alpha back-end (MD files). They
>> are properly emitted when the flag -O0 is enabled. Since they have no side
>> effects and no dependencies on other instructions, they are omitted when
>> flag -O1 is engaged. Is there a way (I mean attribute/constraint in their MD
>> patterns) to avoid that and keep the extra instructions in any case ?
>>     
>
> Depends on how you modeled your instructions.  You could use
> unspec_volatile, but if you modeled "normal" instructions, you have to
> somehow make the side-effects of your instructions clear.   Otherwise,
> dead code elimination will just remove the instructions (no
> dependencies -> dead).
>
> But you'd have to show what you're doing and what you're trying to
> achieve, exactly, for a more helpful answer ;-)
>
> Gr.
> Steven
>   



More information about the Gcc mailing list