PowerPC: Treat llvm.fma.f* intrinsic as using CTR with SPE
authorJustin Hibbits <jrh29@alumni.cwru.edu>
Sun, 19 Apr 2020 04:09:30 +0000 (23:09 -0500)
committerJustin Hibbits <jrh29@alumni.cwru.edu>
Tue, 12 May 2020 22:19:43 +0000 (17:19 -0500)
commit0138cc012506d5195ba2a3cf8a98ceb84c5aeffa
tree6b4811254a82fde4101890181472fa9e91575dd5
parent293c6d382128a0e52a144cec901932d71e072760
PowerPC: Treat llvm.fma.f* intrinsic as using CTR with SPE

Summary:
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.

Reviewed By: shchenz
Differential Revision: https://reviews.llvm.org/D78668
llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
llvm/test/CodeGen/PowerPC/spe.ll