Consider the following test cases:
double fma_1(double rs1, double rs2, double rs3)
{
return -(rs1 * rs2) - rs3;
}
double fma_2(double rs1, double rs2, double rs3)
{
return -(rs1 * rs2) + rs3;
}
The compiled assembly code with command --target=riscv64-unknown-elf
-march=rv64g is:
fma_1:
fneg.d ft0, fa0
fmul.d ft0, ft0, fa1
fsub.d fa0, ft0, fa2
ret
fma_2:
fmul.d ft0, fa0, fa1
fsub.d fa0, fa2, ft0
ret
Compare with the gcc compiled result:
fma_1:
fnmadd.d fa0,fa0,fa1,fa2
fma_2:
fnmsub.d fa0,fa0,fa1,fa2
So I add new patterns for these two scenarios.
Unrelated?