On PowerPC, FNMSUB (including VSX and non-VSX version) means -(a*b-c). But the backend now generates these instructions regardless whether nsz flag exists or not.
If a*b-c==0, such transformation changes sign of zero. This patch fixes this issue.
Paths
| Differential D76585
[PowerPC] Require NSZ flag for c-a*b to FNMSUB ClosedPublic Authored by qiucf on Mar 22 2020, 8:57 PM.
Details
Summary On PowerPC, FNMSUB (including VSX and non-VSX version) means -(a*b-c). But the backend now generates these instructions regardless whether nsz flag exists or not. If a*b-c==0, such transformation changes sign of zero. This patch fixes this issue.
Diff Detail
Unit TestsFailed
Event TimelineHerald added subscribers: llvm-commits, steven.zhang, shchenz and 3 others. · View Herald Transcript qiucf added a child revision: D75344: [PowerPC] Exploit VSX neg, abs and nabs instruction for f32.Mar 22 2020, 10:16 PM
qiucf mentioned this in D76832: [Legalizer] Pass missing SDNodeFlags in split/scalarize vector results.Mar 26 2020, 2:57 AM qiucf marked 2 inline comments as done. qiucf added inline comments. spatel added inline comments.
jsji added a parent revision: D76832: [Legalizer] Pass missing SDNodeFlags in split/scalarize vector results. Comment Actions @steven.zhang Can you please *Disable* or *Delete* the deprecated account @qshanz to avoid confusion. Thanks. amyk added inline comments.
Comment Actions
I have updated the profile. Thank you for reminder. qiucf marked 6 inline comments as done. Comment ActionsAddress comments
qiucf removed a child revision: D75344: [PowerPC] Exploit VSX neg, abs and nabs instruction for f32.Apr 7 2020, 11:39 PM qiucf added inline comments. qiucf marked 3 inline comments as done. Comment ActionsAddress comments from Steven
Comment Actions
I can't say for sure, but my guess is that target-specific logic could be added without incurring the overhead of general discussion/approval: There's also a question of deciding what name corresponds to each math operation. The x86 instructions don't match PPC. For example: It would be nice to have common nodes/optimizations if we can find enough code to share. If we do that, we also need to see if other targets can benefit (AArch64 has fnmsub machine IR). Comment Actions
Thank you for the information. Maybe,we can add fmsub(A*B-C), fnmsub(-A*B-C), fnmadd(-A*B+C). But yes, we need to see if other targets can benefit from this.
qiucf marked an inline comment as done. Comment ActionsAddress Steven's comments. Fixed a crash due to type legalizing. Comment Actions LGTM now overall with some minor comments. As you are adding the pattern for VNMSUBFP, I would suggest you do it in another patch.
Comment Actions LGTM now as far as you update the comments in getNegatedExpression about why we are changing the sign of zero. But please hold on several days in case others have more comments, This revision is now accepted and ready to land.May 28 2020, 3:27 AM Closed by commit rG7a001a2d92a7: [PowerPC] Require nsz flag for c-a*b to FNMSUB (authored by qiucf). · Explain WhyJun 4 2020, 2:08 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 257233 llvm/lib/Target/PowerPC/PPCISelLowering.h
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCInstrInfo.td
llvm/lib/Target/PowerPC/PPCInstrVSX.td
llvm/test/CodeGen/PowerPC/combine-fneg.ll
llvm/test/CodeGen/PowerPC/fma-assoc.ll
llvm/test/CodeGen/PowerPC/fma-ext.ll
llvm/test/CodeGen/PowerPC/fma-negate.ll
llvm/test/CodeGen/PowerPC/fma.ll
llvm/test/CodeGen/PowerPC/repeated-fp-divisors.ll
|
clang-format: please reformat the code