This is an archive of the discontinued LLVM Phabricator instance.

[RISCV]Add more pattern for fma ins
AbandonedPublic

Authored by wf520gg on Feb 19 2023, 11:47 PM.

Details

Reviewers
None
Summary

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.

Diff Detail

Event Timeline

wf520gg created this revision.Feb 19 2023, 11:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 19 2023, 11:47 PM
wf520gg requested review of this revision.Feb 19 2023, 11:47 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 19 2023, 11:47 PM
craig.topper added inline comments.
lldb/include/lldb/Target/Target.h
416

Unrelated?

These transforms are not valid without the contract fast math flag

wf520gg abandoned this revision.Feb 19 2023, 11:54 PM

I posted https://reviews.llvm.org/D144447 to get these in the frontend.