The SPE doesn't have a 'fma' instruction, so the intrinsic becomes a
libcall. It really should become an expansion to two instructions, but
for some reason the compiler doesn't think that's as optimal as a
branch. Since this lowering is done after CTR is allocated for loops,
tell the optimizer that CTR may be used in this case. This prevents a
"Invalid PPC CTR loop!" assertion in the case that a fma() function call
is used in a C/C++ file, and clang converts it into an intrinsic.
Details
- Reviewers
shchenz - Group Reviewers
Restricted Project - Commits
- rG0138cc012506: PowerPC: Treat llvm.fma.f* intrinsic as using CTR with SPE
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp | ||
---|---|---|
320 | In PPCTargetLowering::PPCTargetLowering, We already have if (Subtarget.hasSPE()) { setOperationAction(ISD::FMA , MVT::f64, Expand); setOperationAction(ISD::FMA , MVT::f32, Expand); } And there is a hook function TLI->isOperationLegalOrCustom(Opcode, EVTy) at line 415. I think better to use that function to check if one operation with a type is legal or not, similar with following Intrinsic::sqrt? | |
llvm/test/CodeGen/PowerPC/spe.ll | ||
1405 | Accidentally delete? |
llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp | ||
---|---|---|
320 | I'm surprised I missed that, quite the oversight. Yes, that test below is much preferred, I was afraid I might need to play whack-a-mole on this, and wondering why that wasn't the case except for FMA. Fixing it to the better way. | |
llvm/test/CodeGen/PowerPC/spe.ll | ||
1405 | Yeah. a botched rebase sorting my local commits. |
Address feedback from @shchenz. Much better!
Questionable on the sorting where I put the intrinsic check, there doesn't
appear to be any kind of sort order, so hope it's fine.
In PPCTargetLowering::PPCTargetLowering, We already have
And there is a hook function TLI->isOperationLegalOrCustom(Opcode, EVTy) at line 415. I think better to use that function to check if one operation with a type is legal or not, similar with following Intrinsic::sqrt?