Hi, I have the following code in my rs6000.md (I haven't used new TARGET_* yet) :
(define_expand "add_truncdfsf3" [(set (match_operand:SF 0 "gpc_reg_operand") (float_truncate:SF (plus:DF (match_operand:DF 1 "gpc_reg_operand") (match_operand:DF 2 "gpc_reg_operand"))))] "TARGET_HARD_FLOAT" "") (define_insn "*add_truncdfsf3_fpr" [(set (match_operand:SF 0 "gpc_reg_operand" "=f,wa") (float_truncate:SF (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%d,wa") (match_operand:DF 2 "gpc_reg_operand" "d,wa"))))] "TARGET_HARD_FLOAT" "@ fadds %0,%1,%2 xsaddsp %x0,%x1,%x2" [(set_attr "type" "fp")]) with following optab in optabs.def : OPTAB_CD(fadd_optab, "add_trunc$b$a3") (what is the difference between $b$a and $a$b?) I have also tried adding fadd, add_truncdfsf3 in rs6000-builtin.def, examined rtl dumps multiple times but couldn't get fadd to be exapanded. What am I missing here? Thanks, Tejas On Sun, 11 Aug 2019 at 22:29, Segher Boessenkool <seg...@kernel.crashing.org> wrote: > > Hi Tejas, > > On Sat, Aug 10, 2019 at 04:00:53PM +0530, Tejas Joshi wrote: > > +(define_expand "add_truncdfsf3" > > + [(set (float_extend:DF (match_operand:SF 0 "gpc_reg_operand")) > > + (plus:DF (match_operand:DF 1 "gpc_reg_operand") > > + (match_operand:DF 2 "gpc_reg_operand")))] > > + "TARGET_HARD_FLOAT" > > + "") > > float_extend on the LHS is never correct. I think the following should > work, never mind that it looks like it does double rounding, because it > doesn't (famous last words ;-) ): > > (define_expand "add_truncdfsf3" > [(set (match_operand:SF 0 "gpc_reg_operand") > (float_truncate:SF > (plus:DF (match_operand:DF 1 "gpc_reg_operand") > (match_operand:DF 2 "gpc_reg_operand"))))] > "TARGET_HARD_FLOAT" > "") > > > +(define_insn "*add_truncdfsf3_fpr" > > + [(set (float_extend:DF (match_operand:SF 0 "gpc_reg_operand" "=<Ff>")) > > + (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%<Ff>") > > + (match_operand:DF 2 "gpc_reg_operand" "<Ff>")))] > > + "TARGET_HARD_FLOAT" > > + "fadd %0,%1,%2" > > + [(set_attr "type" "fp")]) > > The constraints should be "f", "%d", "d", respectively. <Ff> says to > display something for the mode in a mode iterator. There is no mode > iterator here. (In what you copied this from, there was SFDF). > > You want to output "fadds", not "fadd". > > Maybe it is easier to immediately write the VSX scalar version for this > as well? That's xsaddsp. Oh, and you need to restrict all of this to > more recent CPUs, we'll have to do some new TARGET_* flag for that I > think. > > Finally: please send patches to gcc-patches@ (not gcc@). > > Thanks, > > > Segher