first i want to generate a three-operator multiply-add instruction similar
to four-operator multiply-add instruction in mips4 instruction sets.
i modify the gcc/config/mips/mips.md file as follow:
(define_peephole2
[ (set (match_operand:SF 0 "register_operand" "=f")
(mult:SF (match_operand:SF 1 "register_operand" "f")
(match_operand:SF 2 "register_operand" "f")))
(set (match_operand:SF 3 "register_operand" "=f")
(plus:SF (match_operand:SF 4 "register_operand" "f")
(match_operand:SF 5 "register_operand" "f")))]
"ISA_HAS_MADD && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT &&
TARGET_FUSED_MADD
&& ((rtx_equal_p(operands[3], operands[4]) && rtx_equal_p(operands[0],
operands[5]))
|| (rtx_equal_p(operands[3], operands[5]) && rtx_equal_p(operands[0],
operands[4])))"
[(set (match_operand:SF 3 "register_operand" "=f")
(plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
(match_operand:SF 2 "register_operand" "f"))
(match_dup 3)))
(clobber (match_dup 0))]
"")
(define_insn ""
[(set (match_operand:DF 0 "register_operand" "=f")
(plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
(match_operand:DF 2 "register_operand" "f"))
(match_dup 0)))]
"ISA_HAS_MADD && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT &&
TARGET_FUSED_MADD "
"madd.d\t%0,%1,%2"
[(set_attr "type" "fmadd")
(set_attr "mode" "DF")])
in many spec2000 cases , it can success to generate multiply-add
instrutions, but the problem i encounter now is:
original program is:
mul.d $f1, $f1, $f0
add.d $f2, $f2, $f1
div.d $f3, $f0, $f1;
after i compile used my changed gcc, it becomes:
madd.d $f2, $f1, $0
div.d $f3, $f0, $f1
as you can see, the value of $f1 is wrong!!
How can i avoid it? modify my md???