Lines Matching refs:CI
79 bool replaceWithNative(CallInst *CI, const FuncInfo &FInfo);
84 bool TDOFold(CallInst *CI, const FuncInfo &FInfo);
89 bool fold_recip(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
92 bool fold_divide(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
95 bool fold_pow(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
98 bool fold_rootn(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
101 bool fold_fma_mad(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
112 bool fold_exp(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
115 bool fold_exp2(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
118 bool fold_exp10(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
121 bool fold_log(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
124 bool fold_log2(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
127 bool fold_log10(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
130 bool fold_sqrt(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
133 bool fold_sincos(CallInst * CI, IRBuilder<> &B, AliasAnalysis * AA);
136 bool fold_read_write_pipe(CallInst *CI, IRBuilder<> &B, FuncInfo &FInfo);
146 CallInst *CI; member in llvm::AMDGPULibCalls
148 bool isUnsafeMath(const CallInst *CI) const;
151 CI->replaceAllUsesWith(With); in replaceCall()
152 CI->eraseFromParent(); in replaceCall()
156 bool fold(CallInst *CI, AliasAnalysis *AA = nullptr);
161 bool useNative(CallInst *CI);
488 bool AMDGPULibCalls::isUnsafeMath(const CallInst *CI) const { in isUnsafeMath()
489 if (auto Op = dyn_cast<FPMathOperator>(CI)) in isUnsafeMath()
492 const Function *F = CI->getParent()->getParent(); in isUnsafeMath()
543 CI = aCI; in useNative()
575 bool AMDGPULibCalls::fold_read_write_pipe(CallInst *CI, IRBuilder<> &B, in fold_read_write_pipe() argument
577 auto *Callee = CI->getCalledFunction(); in fold_read_write_pipe()
585 auto NumArg = CI->getNumArgOperands(); in fold_read_write_pipe()
588 auto *PacketSize = CI->getArgOperand(NumArg - 2); in fold_read_write_pipe()
589 auto *PacketAlign = CI->getArgOperand(NumArg - 1); in fold_read_write_pipe()
602 unsigned PtrArgLoc = CI->getNumArgOperands() - 3; in fold_read_write_pipe()
603 auto PtrArg = CI->getArgOperand(PtrArgLoc); in fold_read_write_pipe()
609 ArgTys.push_back(CI->getArgOperand(I)->getType()); in fold_read_write_pipe()
623 Args.push_back(CI->getArgOperand(I)); in fold_read_write_pipe()
627 NCI->setAttributes(CI->getAttributes()); in fold_read_write_pipe()
628 CI->replaceAllUsesWith(NCI); in fold_read_write_pipe()
629 CI->dropAllReferences(); in fold_read_write_pipe()
630 CI->eraseFromParent(); in fold_read_write_pipe()
636 bool AMDGPULibCalls::fold(CallInst *CI, AliasAnalysis *AA) { in fold() argument
637 this->CI = CI; in fold()
638 Function *Callee = CI->getCalledFunction(); in fold()
648 if (CI->getNumArgOperands() != FInfo.getNumArgs()) in fold()
651 BasicBlock *BB = CI->getParent(); in fold()
652 LLVMContext &Context = CI->getParent()->getContext(); in fold()
656 B.SetInsertPoint(BB, CI->getIterator()); in fold()
659 if (const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(CI)) in fold()
662 if (TDOFold(CI, FInfo)) in fold()
668 if (isUnsafeMath(CI) && evaluateCall(CI, FInfo)) in fold()
678 return (getVecSize(FInfo) != 1) ? false : fold_recip(CI, B, FInfo); in fold()
685 return (getVecSize(FInfo) != 1) ? false : fold_divide(CI, B, FInfo); in fold()
690 return fold_pow(CI, B, FInfo); in fold()
694 return (getVecSize(FInfo) != 1) ? false : fold_rootn(CI, B, FInfo); in fold()
700 return (getVecSize(FInfo) != 1) ? false : fold_fma_mad(CI, B, FInfo); in fold()
703 return isUnsafeMath(CI) && fold_sqrt(CI, B, FInfo); in fold()
709 return fold_sincos(CI, B, AA); in fold()
716 return fold_read_write_pipe(CI, B, FInfo); in fold()
725 bool AMDGPULibCalls::TDOFold(CallInst *CI, const FuncInfo &FInfo) { in TDOFold() argument
733 Value *opr0 = CI->getArgOperand(0); in TDOFold()
755 LLVMContext &context = CI->getParent()->getParent()->getContext(); in TDOFold()
768 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *nval << "\n"); in TDOFold()
778 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *nval << "\n"); in TDOFold()
789 bool AMDGPULibCalls::replaceWithNative(CallInst *CI, const FuncInfo &FInfo) { in replaceWithNative() argument
790 Module *M = CI->getModule(); in replaceWithNative()
799 LLVM_DEBUG(dbgs() << "AMDIC: " << *CI << " ---> "); in replaceWithNative()
801 CI->setCalledFunction(FPExpr); in replaceWithNative()
803 LLVM_DEBUG(dbgs() << *CI << '\n'); in replaceWithNative()
811 bool AMDGPULibCalls::fold_recip(CallInst *CI, IRBuilder<> &B, in fold_recip() argument
813 Value *opr0 = CI->getArgOperand(0); in fold_recip()
821 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *nval << "\n"); in fold_recip()
829 bool AMDGPULibCalls::fold_divide(CallInst *CI, IRBuilder<> &B, in fold_divide() argument
831 Value *opr0 = CI->getArgOperand(0); in fold_divide()
832 Value *opr1 = CI->getArgOperand(1); in fold_divide()
859 bool AMDGPULibCalls::fold_pow(CallInst *CI, IRBuilder<> &B, in fold_pow() argument
872 opr0 = CI->getArgOperand(0); in fold_pow()
873 opr1 = CI->getArgOperand(1); in fold_pow()
891 if (!isUnsafeMath(CI) && !CF && !CINT && !CZero) in fold_pow()
899 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> 1\n"); in fold_pow()
909 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << "\n"); in fold_pow()
915 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << " * " << *opr0 in fold_pow()
923 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> 1 / " << *opr0 << "\n"); in fold_pow()
933 Module *M = CI->getModule(); in fold_pow()
940 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " in fold_pow()
949 if (!isUnsafeMath(CI)) in fold_pow()
997 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " in fold_pow()
1124 opr_n = CI->getArgOperand(1); in fold_pow()
1136 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " in fold_pow()
1143 bool AMDGPULibCalls::fold_rootn(CallInst *CI, IRBuilder<> &B, in fold_rootn() argument
1145 Value *opr0 = CI->getArgOperand(0); in fold_rootn()
1146 Value *opr1 = CI->getArgOperand(1); in fold_rootn()
1154 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << "\n"); in fold_rootn()
1161 Module *M = CI->getModule(); in fold_rootn()
1164 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> sqrt(" << *opr0 << ")\n"); in fold_rootn()
1170 Module *M = CI->getModule(); in fold_rootn()
1173 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> cbrt(" << *opr0 << ")\n"); in fold_rootn()
1179 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> 1.0 / " << *opr0 << "\n"); in fold_rootn()
1188 Module *M = CI->getModule(); in fold_rootn()
1191 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> rsqrt(" << *opr0 in fold_rootn()
1201 bool AMDGPULibCalls::fold_fma_mad(CallInst *CI, IRBuilder<> &B, in fold_fma_mad() argument
1203 Value *opr0 = CI->getArgOperand(0); in fold_fma_mad()
1204 Value *opr1 = CI->getArgOperand(1); in fold_fma_mad()
1205 Value *opr2 = CI->getArgOperand(2); in fold_fma_mad()
1211 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr2 << "\n"); in fold_fma_mad()
1217 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr1 << " + " << *opr2 in fold_fma_mad()
1225 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << " + " << *opr2 in fold_fma_mad()
1234 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << " * " in fold_fma_mad()
1255 bool AMDGPULibCalls::fold_sqrt(CallInst *CI, IRBuilder<> &B, in fold_sqrt() argument
1260 CI->getModule(), AMDGPULibFunc(AMDGPULibFunc::EI_SQRT, FInfo))) { in fold_sqrt()
1261 Value *opr0 = CI->getArgOperand(0); in fold_sqrt()
1262 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " in fold_sqrt()
1273 bool AMDGPULibCalls::fold_sincos(CallInst *CI, IRBuilder<> &B, in fold_sincos() argument
1276 if (!AMDGPULibFunc::parse(CI->getCalledFunction()->getName(), fInfo)) in fold_sincos()
1283 Value *CArgVal = CI->getArgOperand(0); in fold_sincos()
1284 BasicBlock * const CBB = CI->getParent(); in fold_sincos()
1297 CArgVal = CI->getArgOperand(0); in fold_sincos()
1302 Module *M = CI->getModule(); in fold_sincos()
1309 if (!XI || XI == CI || XI->getParent() != CBB) in fold_sincos()
1316 BasicBlock::iterator BBI = CI->getIterator(); in fold_sincos()
1317 if (BBI == CI->getParent()->begin()) in fold_sincos()
1353 LLVM_DEBUG(errs() << "AMDIC: fold_sincos (" << *CI << ", " << *UI << ") with " in fold_sincos()
1360 CI->replaceAllUsesWith(Reload); in fold_sincos()
1362 CI->eraseFromParent(); in fold_sincos()
1366 CI->replaceAllUsesWith(Call); in fold_sincos()
1368 CI->eraseFromParent(); in fold_sincos()
1641 LLVMContext &context = CI->getParent()->getParent()->getContext(); in evaluateCall()
1644 nval0 = ConstantFP::get(CI->getType(), DVal0[0]); in evaluateCall()
1646 nval1 = ConstantFP::get(CI->getType(), DVal1[0]); in evaluateCall()
1726 CallInst *CI = dyn_cast<CallInst>(I); in runOnFunction() local
1728 if (!CI) continue; in runOnFunction()
1731 Function *Callee = CI->getCalledFunction(); in runOnFunction()
1734 LLVM_DEBUG(dbgs() << "AMDIC: try folding " << *CI << "\n"; in runOnFunction()
1736 if(Simplifier.fold(CI, AA)) in runOnFunction()
1751 CallInst *CI = dyn_cast<CallInst>(I); in runOnFunction() local
1753 if (!CI) continue; in runOnFunction()
1756 Function *Callee = CI->getCalledFunction(); in runOnFunction()
1759 if(Simplifier.useNative(CI)) in runOnFunction()