Reducing JUMPs and using conditional exec based on if_then_else

Sami Khawam S.Khawam@ee.ed.ac.uk
Sun Nov 28 17:13:00 GMT 2004


Hi,

I am still trying to learn the internals of gcc and 
the .md architecture description files, and I would 
be very grateful if anyone can help with the following.

I have built a CPU architecture (based on the 
OpenRISC .md files) where I would like to reduce the 
number of jump calls to a minimum and use other 
altervatives like conditional execution. I have set 
BRANCH_COST to 40 and REGISTER_MOVE_COST to 0 (so it 
can use as many MOVs at it wants) and added the 2 
insns (see below) to the .md file defining two 
conditional moves, one based on cond_exec and the 
other on if_then_else (is such thing possible?).
The problem is that the compiler cannot do any of 
the required optimizations.
Is this a limitation in ifcvt.c? Or is it me doing 
something wrong?



The insns added:

(define_insn "cond_exec_movsi"
   [(cond_exec
    (ne:CC (const_int 0) (reg:CC 32))
    (set (match_operand:SI 0 "register_operand" "=r")
	(match_operand:SI 1 "register_operand"  "r")
	  ) )]
   ""
   "CMOV %0, %1"
)

(define_insn "if_else_movsi"
   [(set (match_operand:SI 0 "register_operand" "=r")
    (if_then_else (ne:CC (const_int 0) (reg:CC 32))
     (match_operand:SI 1 "register_operand"  "r")
     (match_operand:SI 2 "register_operand"  "r")
		      ))]
   ""
   "CMOV_ELSE %0, %1, %2"
)



Thanks for your help,

Sami Khawam



More information about the Gcc mailing list