From 0b37175ca6822aafdbf5352cbbf469f2bf0bf1bd Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Sun, 27 Mar 2016 05:40:56 +0000 Subject: [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 --- llvm/lib/Target/PowerPC/PPCCTRLoops.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'llvm/lib') 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); -- cgit v1.2.3