diff options
author | Hal Finkel <hfinkel@anl.gov> | 2016-03-27 05:40:56 +0000 |
---|---|---|
committer | Hal Finkel <hfinkel@anl.gov> | 2016-03-27 05:40:56 +0000 |
commit | 0b37175ca6822aafdbf5352cbbf469f2bf0bf1bd (patch) | |
tree | a00c230c7a1fd11def9099f07bc1cc84fdf94ef5 /llvm/lib/Target/PowerPC/PPCCTRLoops.cpp | |
parent | f95aa56c79b6e0706be737e8f5d3f50fb7553c5c (diff) | |
download | bcm5719-llvm-0b37175ca6822aafdbf5352cbbf469f2bf0bf1bd.tar.gz bcm5719-llvm-0b37175ca6822aafdbf5352cbbf469f2bf0bf1bd.zip |
[PowerPC] Map max/minnum intrinsics and fmax/fmin to ISD nodes for CTR-based loop legality
Intrinsic::maxnum and Intrinsic::minnum, along with the associated libc
function calls (fmax[f], etc.) generally map to function calls after lowering.
For some vector types with QPX at least, however, we can legally lower these,
and we don't need to prohibit CTR-based loops on their account.
It turned out, however, that the logic that checked the opcodes associated with
intrinsics was broken (it would set the Opcode variable, but that variable was
later checked only if set for some otherwise-external function call.
This fixes the latter problem and adds the FMAX/MINNUM mappings.
llvm-svn: 264532
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCCTRLoops.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCCTRLoops.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp index 2a1cb608c7b..643d327b321 100644 --- a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp +++ b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp @@ -245,7 +245,7 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) { if (Function *F = CI->getCalledFunction()) { // Most intrinsics don't become function calls, but some might. // sin, cos, exp and log are always calls. - unsigned Opcode; + unsigned Opcode = 0; if (F->getIntrinsicID() != Intrinsic::not_intrinsic) { switch (F->getIntrinsicID()) { default: continue; @@ -291,8 +291,6 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) { case Intrinsic::pow: case Intrinsic::sin: case Intrinsic::cos: - case Intrinsic::maxnum: - case Intrinsic::minnum: return true; case Intrinsic::copysign: if (CI->getArgOperand(0)->getType()->getScalarType()-> @@ -307,6 +305,8 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) { case Intrinsic::rint: Opcode = ISD::FRINT; break; case Intrinsic::nearbyint: Opcode = ISD::FNEARBYINT; break; case Intrinsic::round: Opcode = ISD::FROUND; break; + case Intrinsic::minnum: Opcode = ISD::FMINNUM; break; + case Intrinsic::maxnum: Opcode = ISD::FMAXNUM; break; } } @@ -366,8 +366,18 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) { case LibFunc::truncf: case LibFunc::truncl: Opcode = ISD::FTRUNC; break; + case LibFunc::fmin: + case LibFunc::fminf: + case LibFunc::fminl: + Opcode = ISD::FMINNUM; break; + case LibFunc::fmax: + case LibFunc::fmaxf: + case LibFunc::fmaxl: + Opcode = ISD::FMAXNUM; break; } + } + if (Opcode) { auto &DL = CI->getModule()->getDataLayout(); MVT VTy = TLI->getSimpleValueType(DL, CI->getArgOperand(0)->getType(), true); |