Lines Matching refs:FInfo

76   bool replaceWithNative(CallInst *CI, const FuncInfo &FInfo);
79 FuncInfo *FInfo=nullptr /*out*/);
81 bool TDOFold(CallInst *CI, const FuncInfo &FInfo);
86 bool fold_recip(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
89 bool fold_divide(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
92 bool fold_pow(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
95 bool fold_rootn(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
98 bool fold_fma_mad(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
101 bool sincosUseNative(CallInst *aCI, const FuncInfo &FInfo);
104 bool evaluateScalarMathFunc(FuncInfo &FInfo, double& Res0,
106 bool evaluateCall(CallInst *aCI, FuncInfo &FInfo);
109 bool fold_exp(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
112 bool fold_exp2(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
115 bool fold_exp10(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
118 bool fold_log(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
121 bool fold_log2(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
124 bool fold_log10(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
127 bool fold_sqrt(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
133 bool fold_read_write_pipe(CallInst *CI, IRBuilder<> &B, FuncInfo &FInfo);
143 FunctionCallee getNativeFunction(Module *M, const FuncInfo &FInfo);
467 static inline int getVecSize(const AMDGPULibFunc& FInfo) { in getVecSize() argument
468 return FInfo.getLeads()[0].VectorSize; in getVecSize()
471 static inline AMDGPULibFunc::EType getArgType(const AMDGPULibFunc& FInfo) { in getArgType() argument
472 return (AMDGPULibFunc::EType)FInfo.getLeads()[0].ArgType; in getArgType()
484 FuncInfo *FInfo) { in parseFunctionName() argument
485 return AMDGPULibFunc::parse(FMangledName, *FInfo); in parseFunctionName()
507 bool AMDGPULibCalls::sincosUseNative(CallInst *aCI, const FuncInfo &FInfo) { in sincosUseNative() argument
516 nf.getLeads()[0].ArgType = FInfo.getLeads()[0].ArgType; in sincosUseNative()
517 nf.getLeads()[0].VectorSize = FInfo.getLeads()[0].VectorSize; in sincosUseNative()
545 FuncInfo FInfo; in useNative() local
546 if (!parseFunctionName(Callee->getName(), &FInfo) || !FInfo.isMangled() || in useNative()
547 FInfo.getPrefix() != AMDGPULibFunc::NOPFX || in useNative()
548 getArgType(FInfo) == AMDGPULibFunc::F64 || !HasNative(FInfo.getId()) || in useNative()
549 !(AllNative || useNativeFunc(FInfo.getName()))) { in useNative()
553 if (FInfo.getId() == AMDGPULibFunc::EI_SINCOS) in useNative()
554 return sincosUseNative(aCI, FInfo); in useNative()
556 FInfo.setPrefix(AMDGPULibFunc::NATIVE); in useNative()
557 FunctionCallee F = getFunction(aCI->getModule(), FInfo); in useNative()
575 FuncInfo &FInfo) { in fold_read_write_pipe() argument
660 FuncInfo FInfo; in fold() local
661 if (!parseFunctionName(Callee->getName(), &FInfo)) in fold()
665 if (CI->getNumArgOperands() != FInfo.getNumArgs()) in fold()
668 if (TDOFold(CI, FInfo)) in fold()
674 if (isUnsafeMath(CI) && evaluateCall(CI, FInfo)) in fold()
678 switch (FInfo.getId()) { in fold()
681 assert ((FInfo.getPrefix() == AMDGPULibFunc::NATIVE || in fold()
682 FInfo.getPrefix() == AMDGPULibFunc::HALF) && in fold()
684 return (getVecSize(FInfo) != 1) ? false : fold_recip(CI, B, FInfo); in fold()
688 assert ((FInfo.getPrefix() == AMDGPULibFunc::NATIVE || in fold()
689 FInfo.getPrefix() == AMDGPULibFunc::HALF) && in fold()
691 return (getVecSize(FInfo) != 1) ? false : fold_divide(CI, B, FInfo); in fold()
696 return fold_pow(CI, B, FInfo); in fold()
700 return (getVecSize(FInfo) != 1) ? false : fold_rootn(CI, B, FInfo); in fold()
706 return (getVecSize(FInfo) != 1) ? false : fold_fma_mad(CI, B, FInfo); in fold()
709 return isUnsafeMath(CI) && fold_sqrt(CI, B, FInfo); in fold()
712 if ((getArgType(FInfo) == AMDGPULibFunc::F32 || in fold()
713 getArgType(FInfo) == AMDGPULibFunc::F64) in fold()
714 && (FInfo.getPrefix() == AMDGPULibFunc::NOPFX)) in fold()
722 return fold_read_write_pipe(CI, B, FInfo); in fold()
731 bool AMDGPULibCalls::TDOFold(CallInst *CI, const FuncInfo &FInfo) { in TDOFold() argument
733 const TableRef tr = getOptTable(FInfo.getId()); in TDOFold()
741 if (getVecSize(FInfo) > 1) { in TDOFold()
744 for (int eltNo = 0; eltNo < getVecSize(FInfo); ++eltNo) { in TDOFold()
763 if (getArgType(FInfo) == AMDGPULibFunc::F32) { in TDOFold()
795 bool AMDGPULibCalls::replaceWithNative(CallInst *CI, const FuncInfo &FInfo) { in replaceWithNative() argument
797 if (getArgType(FInfo) != AMDGPULibFunc::F32 || in replaceWithNative()
798 FInfo.getPrefix() != AMDGPULibFunc::NOPFX || in replaceWithNative()
799 !HasNative(FInfo.getId())) in replaceWithNative()
802 AMDGPULibFunc nf = FInfo; in replaceWithNative()
818 const FuncInfo &FInfo) { in fold_recip() argument
836 const FuncInfo &FInfo) { in fold_divide() argument
843 (CF1 && (getArgType(FInfo) == AMDGPULibFunc::F32))) in fold_divide()
866 const FuncInfo &FInfo) { in fold_pow() argument
867 assert((FInfo.getId() == AMDGPULibFunc::EI_POW || in fold_pow()
868 FInfo.getId() == AMDGPULibFunc::EI_POWR || in fold_pow()
869 FInfo.getId() == AMDGPULibFunc::EI_POWN) && in fold_pow()
881 if (getVecSize(FInfo) == 1) { in fold_pow()
907 if (getVecSize(FInfo) > 1) { in fold_pow()
908 cnval = ConstantDataVector::getSplat(getVecSize(FInfo), cnval); in fold_pow()
931 if (getVecSize(FInfo) > 1) { in fold_pow()
932 cnval = ConstantDataVector::getSplat(getVecSize(FInfo), cnval); in fold_pow()
946 FInfo))) { in fold_pow()
948 << FInfo.getName().c_str() << "(" << *opr0 << ")\n"); in fold_pow()
963 double dval = (getArgType(FInfo) == AMDGPULibFunc::F32) in fold_pow()
981 if (getVecSize(FInfo) > 1) { in fold_pow()
982 cnval = ConstantDataVector::getSplat(getVecSize(FInfo), cnval); in fold_pow()
999 if (getVecSize(FInfo) > 1) { in fold_pow()
1000 cnval = ConstantDataVector::getSplat(getVecSize(FInfo), cnval); in fold_pow()
1014 getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_EXP2, FInfo)); in fold_pow()
1022 if (getVecSize(FInfo) == 1) { in fold_pow()
1026 double V = (getArgType(FInfo) == AMDGPULibFunc::F32) in fold_pow()
1032 needcopysign = (FInfo.getId() != AMDGPULibFunc::EI_POWR) && in fold_pow()
1036 needcopysign = needabs = FInfo.getId() != AMDGPULibFunc::EI_POWR && in fold_pow()
1044 needcopysign = needabs = FInfo.getId() != AMDGPULibFunc::EI_POWR; in fold_pow()
1046 assert ((int)CDV->getNumElements() == getVecSize(FInfo) && in fold_pow()
1050 for (int i=0; i < getVecSize(FInfo); ++i) { in fold_pow()
1051 double V = (getArgType(FInfo) == AMDGPULibFunc::F32) in fold_pow()
1058 if (getArgType(FInfo) == AMDGPULibFunc::F32) { in fold_pow()
1072 if (needcopysign && (FInfo.getId() == AMDGPULibFunc::EI_POW)) { in fold_pow()
1075 if (getVecSize(FInfo) == 1) { in fold_pow()
1077 double y = (getArgType(FInfo) == AMDGPULibFunc::F32) in fold_pow()
1086 for (int i=0; i < getVecSize(FInfo); ++i) { in fold_pow()
1087 double y = (getArgType(FInfo) == AMDGPULibFunc::F32) in fold_pow()
1101 getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_FABS, FInfo)); in fold_pow()
1110 getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_LOG2, FInfo)); in fold_pow()
1116 if (FInfo.getId() == AMDGPULibFunc::EI_POWN) { in fold_pow()
1151 const FuncInfo &FInfo) { in fold_rootn() argument
1168 getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_SQRT, FInfo))) { in fold_rootn()
1177 getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_CBRT, FInfo))) { in fold_rootn()
1193 getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_RSQRT, FInfo))) { in fold_rootn()
1205 const FuncInfo &FInfo) { in fold_fma_mad() argument
1250 const FuncInfo &FInfo) { in getNativeFunction() argument
1251 if (getArgType(FInfo) == AMDGPULibFunc::F64 || !HasNative(FInfo.getId())) in getNativeFunction()
1253 FuncInfo nf = FInfo; in getNativeFunction()
1260 const FuncInfo &FInfo) { in fold_sqrt() argument
1261 if (getArgType(FInfo) == AMDGPULibFunc::F32 && (getVecSize(FInfo) == 1) && in fold_sqrt()
1262 (FInfo.getPrefix() != AMDGPULibFunc::NATIVE)) { in fold_sqrt()
1264 CI->getModule(), AMDGPULibFunc(AMDGPULibFunc::EI_SQRT, FInfo))) { in fold_sqrt()
1427 bool AMDGPULibCalls::evaluateScalarMathFunc(FuncInfo &FInfo, in evaluateScalarMathFunc() argument
1439 opr0 = (getArgType(FInfo) == AMDGPULibFunc::F64) in evaluateScalarMathFunc()
1445 opr1 = (getArgType(FInfo) == AMDGPULibFunc::F64) in evaluateScalarMathFunc()
1451 opr2 = (getArgType(FInfo) == AMDGPULibFunc::F64) in evaluateScalarMathFunc()
1456 switch (FInfo.getId()) { in evaluateScalarMathFunc()
1622 bool AMDGPULibCalls::evaluateCall(CallInst *aCI, FuncInfo &FInfo) { in evaluateCall() argument
1637 if (FInfo.getId() != AMDGPULibFunc::EI_SINCOS) in evaluateCall()
1651 bool hasTwoResults = (FInfo.getId() == AMDGPULibFunc::EI_SINCOS); in evaluateCall()
1652 if (getVecSize(FInfo) == 1) { in evaluateCall()
1653 if (!evaluateScalarMathFunc(FInfo, DVal0[0], in evaluateCall()
1661 for (int i=0; i < getVecSize(FInfo); ++i) { in evaluateCall()
1665 if (!evaluateScalarMathFunc(FInfo, DVal0[i], in evaluateCall()
1674 if (getVecSize(FInfo) == 1) { in evaluateCall()
1679 if (getArgType(FInfo) == AMDGPULibFunc::F32) { in evaluateCall()
1681 for (int i=0; i < getVecSize(FInfo); ++i) in evaluateCall()
1686 for (int i=0; i < getVecSize(FInfo); ++i) in evaluateCall()
1703 assert(FInfo.getId() == AMDGPULibFunc::EI_SINCOS && in evaluateCall()