This is the mail archive of the gcc@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: Porting question: define_expand Vs define_split


Choosing between define_expand and define_insn_and_split IMHO depends
on whether gcc can optimize better with the split-up insns or with the
combined insn.  In cases with linear math, it's probably better to
define_expand.  In cases where you're splitting up a wide op into
pairs of narrow ops (like movdi->movsi), it's probably better to
define_insn_and_split (and defer until after reload) so gcc can see
the wider ops during optimization.

In the case of a missing neg, though, you can use a not/inc pair if
your machine is 2s-compliment and avoid the need for a scratch
register to hold the zero or op1 (it can be done in place).  You'd
still use a define_expand:

(define_expand "neghi2"
  [(set (match_dup 2)
	(not:HI (match_operand:HI 1 "" "")))
   (set (match_operand:HI 0 "" "")
	(plus:HI (match_dup 2)
                 (const_int 1)))]
  ""
  "operands[2] = gen_reg_rtx (HImode);"
  )

Add "register_operand" if your not/inc ops need registers.


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