This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Treat llvm.fmuladd intrinsic as using CTR
ClosedPublic

Authored by qiucf on May 17 2022, 12:04 AM.

Details

Summary

This fixes bug 55463, similar to D78668. The is a temporary fix since we will switch to post-isel CTR loop determination in the future.

Diff Detail

Event Timeline

qiucf created this revision.May 17 2022, 12:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2022, 12:04 AM
qiucf requested review of this revision.May 17 2022, 12:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2022, 12:04 AM
qiucf added reviewers: Restricted Project, shchenz, amyk, jhibbits, dim.May 17 2022, 12:07 AM
dim accepted this revision.May 17 2022, 11:16 AM

I can confirm that this fixes both my original full test case, and the minimized variant. Since this change resembles D78668, I think it is relatively safe to apply now, and merge to the release/14.x branch?

This revision is now accepted and ready to land.May 17 2022, 11:16 AM
shchenz added inline comments.May 17 2022, 6:46 PM
llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
505

no need for else.
And why we need LLVM_FALLTHROUGH, I don't see any handling for Intrinsic::fmuladd in the switch block below, will break work?

qiucf added inline comments.May 17 2022, 7:17 PM
llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
505

Here FALLTHROUGH sets Opcode = ISD::FMA for fmuladd. Code below checks whether Opcode is legal or custom, otherwise returns true.

shchenz added inline comments.May 17 2022, 7:37 PM
llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
505

Oh, yes, right. Then should case Intrinsic::fma have the same issue handled in case Intrinsic::fmuladd for double double? Or on the other hand, do we need the specific handling in case Intrinsic::fmuladd, will Opcode leagl or custom cover the check for type double double?

llvm/test/CodeGen/PowerPC/pr55463.ll
11

Can add a nounwind attribute for the function to simply the case a little bit.

qiucf updated this revision to Diff 430228.May 17 2022, 8:21 PM
qiucf marked 2 inline comments as done.
qiucf added inline comments.
llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
505

We don't need it. The legal check already handles the special cases (SPE, ppcf128, etc.). All we need is to put fmuladd case here, otherwise default statement just continue and ignore it.

shchenz accepted this revision as: shchenz.May 17 2022, 8:30 PM

LGTM too. Thanks for fixing.

This revision was landed with ongoing or failed builds.May 18 2022, 12:58 AM
This revision was automatically updated to reflect the committed changes.
This comment was removed by shchenz.