Hi Jim,

>>> But my return label is getting optimized away. Could you please tell
>>> me how to avoid this.
>
>You may also need to add a (USE (REG RA)) to the call pattern. Gcc will see that you set a register to the value of the >return label, but it won't see any code that uses that register, so it will optimize away both the load and the label. To >prevent this, you need to add an explicit use of that register to the call insn pattern.

I have that.. :). Here  is the pattern for the call_insn produced.

(define_insn "brc_call_simulate"
 [(call (mem:HI (match_operand 0 "register_operand" "r"))
    (match_operand 1 "" "i"))
  (use (reg:HI 7))
  (clobber (reg:HI 7))]
 ""
 "jr\t%0")

But GCC is not optimizing the load away. Its just the the return label that gets optimized away.

CMIIW, I think the problem is this :
1. The label output is local to this function
2. The label creates a new basic block. There is no jump to this label. As a result, there is only one incoming edge to this block and that is the fall through edge after the return from the call. 3. As a result, GCC tries to merge those two blocks and in the process removes the label.

How do I prevent this ?

Thanks in advance,
Kunal

Reply via email to