Lines Matching refs:CI

62   bool replaceWithNative(CallInst *CI, const FuncInfo &FInfo);
67 bool TDOFold(CallInst *CI, const FuncInfo &FInfo);
72 bool fold_recip(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
75 bool fold_divide(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
78 bool fold_pow(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
81 bool fold_rootn(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
84 bool fold_fma_mad(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
95 bool fold_exp(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
98 bool fold_exp2(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
101 bool fold_exp10(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
104 bool fold_log(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
107 bool fold_log2(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
110 bool fold_log10(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
113 bool fold_sqrt(CallInst *CI, IRBuilder<> &B, const FuncInfo &FInfo);
116 bool fold_sincos(CallInst * CI, IRBuilder<> &B, AliasAnalysis * AA);
119 bool fold_read_write_pipe(CallInst *CI, IRBuilder<> &B, FuncInfo &FInfo);
122 bool fold_wavefrontsize(CallInst *CI, IRBuilder<> &B);
132 CallInst *CI; member in llvm::AMDGPULibCalls
134 bool isUnsafeMath(const CallInst *CI) const;
137 CI->replaceAllUsesWith(With); in replaceCall()
138 CI->eraseFromParent(); in replaceCall()
144 bool fold(CallInst *CI, AliasAnalysis *AA = nullptr);
149 bool useNative(CallInst *CI);
474 bool AMDGPULibCalls::isUnsafeMath(const CallInst *CI) const { in isUnsafeMath()
475 if (auto Op = dyn_cast<FPMathOperator>(CI)) in isUnsafeMath()
478 const Function *F = CI->getParent()->getParent(); in isUnsafeMath()
528 CI = aCI; in useNative()
560 bool AMDGPULibCalls::fold_read_write_pipe(CallInst *CI, IRBuilder<> &B, in fold_read_write_pipe() argument
562 auto *Callee = CI->getCalledFunction(); in fold_read_write_pipe()
570 auto NumArg = CI->getNumArgOperands(); in fold_read_write_pipe()
573 auto *PacketSize = CI->getArgOperand(NumArg - 2); in fold_read_write_pipe()
574 auto *PacketAlign = CI->getArgOperand(NumArg - 1); in fold_read_write_pipe()
587 unsigned PtrArgLoc = CI->getNumArgOperands() - 3; in fold_read_write_pipe()
588 auto PtrArg = CI->getArgOperand(PtrArgLoc); in fold_read_write_pipe()
594 ArgTys.push_back(CI->getArgOperand(I)->getType()); in fold_read_write_pipe()
608 Args.push_back(CI->getArgOperand(I)); in fold_read_write_pipe()
612 NCI->setAttributes(CI->getAttributes()); in fold_read_write_pipe()
613 CI->replaceAllUsesWith(NCI); in fold_read_write_pipe()
614 CI->dropAllReferences(); in fold_read_write_pipe()
615 CI->eraseFromParent(); in fold_read_write_pipe()
621 bool AMDGPULibCalls::fold(CallInst *CI, AliasAnalysis *AA) { in fold() argument
622 this->CI = CI; in fold()
623 Function *Callee = CI->getCalledFunction(); in fold()
628 BasicBlock *BB = CI->getParent(); in fold()
629 LLVMContext &Context = CI->getParent()->getContext(); in fold()
633 B.SetInsertPoint(BB, CI->getIterator()); in fold()
636 if (const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(CI)) in fold()
643 return !EnablePreLink && fold_wavefrontsize(CI, B); in fold()
651 if (CI->getNumArgOperands() != FInfo.getNumArgs()) in fold()
654 if (TDOFold(CI, FInfo)) in fold()
660 if (isUnsafeMath(CI) && evaluateCall(CI, FInfo)) in fold()
670 return (getVecSize(FInfo) != 1) ? false : fold_recip(CI, B, FInfo); in fold()
677 return (getVecSize(FInfo) != 1) ? false : fold_divide(CI, B, FInfo); in fold()
682 return fold_pow(CI, B, FInfo); in fold()
686 return (getVecSize(FInfo) != 1) ? false : fold_rootn(CI, B, FInfo); in fold()
692 return (getVecSize(FInfo) != 1) ? false : fold_fma_mad(CI, B, FInfo); in fold()
695 return isUnsafeMath(CI) && fold_sqrt(CI, B, FInfo); in fold()
701 return fold_sincos(CI, B, AA); in fold()
708 return fold_read_write_pipe(CI, B, FInfo); in fold()
717 bool AMDGPULibCalls::TDOFold(CallInst *CI, const FuncInfo &FInfo) { in TDOFold() argument
725 Value *opr0 = CI->getArgOperand(0); in TDOFold()
747 LLVMContext &context = CI->getParent()->getParent()->getContext(); in TDOFold()
760 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *nval << "\n"); in TDOFold()
770 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *nval << "\n"); in TDOFold()
781 bool AMDGPULibCalls::replaceWithNative(CallInst *CI, const FuncInfo &FInfo) { in replaceWithNative() argument
782 Module *M = CI->getModule(); in replaceWithNative()
791 LLVM_DEBUG(dbgs() << "AMDIC: " << *CI << " ---> "); in replaceWithNative()
793 CI->setCalledFunction(FPExpr); in replaceWithNative()
795 LLVM_DEBUG(dbgs() << *CI << '\n'); in replaceWithNative()
803 bool AMDGPULibCalls::fold_recip(CallInst *CI, IRBuilder<> &B, in fold_recip() argument
805 Value *opr0 = CI->getArgOperand(0); in fold_recip()
813 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *nval << "\n"); in fold_recip()
821 bool AMDGPULibCalls::fold_divide(CallInst *CI, IRBuilder<> &B, in fold_divide() argument
823 Value *opr0 = CI->getArgOperand(0); in fold_divide()
824 Value *opr1 = CI->getArgOperand(1); in fold_divide()
851 bool AMDGPULibCalls::fold_pow(CallInst *CI, IRBuilder<> &B, in fold_pow() argument
864 opr0 = CI->getArgOperand(0); in fold_pow()
865 opr1 = CI->getArgOperand(1); in fold_pow()
883 if (!isUnsafeMath(CI) && !CF && !CINT && !CZero) in fold_pow()
891 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> 1\n"); in fold_pow()
901 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << "\n"); in fold_pow()
907 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << " * " << *opr0 in fold_pow()
915 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> 1 / " << *opr0 << "\n"); in fold_pow()
925 Module *M = CI->getModule(); in fold_pow()
933 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " in fold_pow()
942 if (!isUnsafeMath(CI)) in fold_pow()
990 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " in fold_pow()
1117 opr_n = CI->getArgOperand(1); in fold_pow()
1129 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " in fold_pow()
1136 bool AMDGPULibCalls::fold_rootn(CallInst *CI, IRBuilder<> &B, in fold_rootn() argument
1138 Value *opr0 = CI->getArgOperand(0); in fold_rootn()
1139 Value *opr1 = CI->getArgOperand(1); in fold_rootn()
1147 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << "\n"); in fold_rootn()
1152 Module *M = CI->getModule(); in fold_rootn()
1155 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> sqrt(" << *opr0 << ")\n"); in fold_rootn()
1161 Module *M = CI->getModule(); in fold_rootn()
1164 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> cbrt(" << *opr0 << ")\n"); in fold_rootn()
1170 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> 1.0 / " << *opr0 << "\n"); in fold_rootn()
1177 Module *M = CI->getModule(); in fold_rootn()
1180 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> rsqrt(" << *opr0 in fold_rootn()
1190 bool AMDGPULibCalls::fold_fma_mad(CallInst *CI, IRBuilder<> &B, in fold_fma_mad() argument
1192 Value *opr0 = CI->getArgOperand(0); in fold_fma_mad()
1193 Value *opr1 = CI->getArgOperand(1); in fold_fma_mad()
1194 Value *opr2 = CI->getArgOperand(2); in fold_fma_mad()
1200 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr2 << "\n"); in fold_fma_mad()
1206 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr1 << " + " << *opr2 in fold_fma_mad()
1214 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << " + " << *opr2 in fold_fma_mad()
1223 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " << *opr0 << " * " in fold_fma_mad()
1245 bool AMDGPULibCalls::fold_sqrt(CallInst *CI, IRBuilder<> &B, in fold_sqrt() argument
1250 CI->getModule(), AMDGPULibFunc(AMDGPULibFunc::EI_SQRT, FInfo))) { in fold_sqrt()
1251 Value *opr0 = CI->getArgOperand(0); in fold_sqrt()
1252 LLVM_DEBUG(errs() << "AMDIC: " << *CI << " ---> " in fold_sqrt()
1263 bool AMDGPULibCalls::fold_sincos(CallInst *CI, IRBuilder<> &B, in fold_sincos() argument
1266 if (!AMDGPULibFunc::parse(CI->getCalledFunction()->getName(), fInfo)) in fold_sincos()
1273 Value *CArgVal = CI->getArgOperand(0); in fold_sincos()
1274 BasicBlock * const CBB = CI->getParent(); in fold_sincos()
1289 CArgVal = CI->getArgOperand(0); in fold_sincos()
1294 Module *M = CI->getModule(); in fold_sincos()
1301 if (!XI || XI == CI || XI->getParent() != CBB) in fold_sincos()
1308 BasicBlock::iterator BBI = CI->getIterator(); in fold_sincos()
1309 if (BBI == CI->getParent()->begin()) in fold_sincos()
1347 LLVM_DEBUG(errs() << "AMDIC: fold_sincos (" << *CI << ", " << *UI << ") with " in fold_sincos()
1354 CI->replaceAllUsesWith(Reload); in fold_sincos()
1356 CI->eraseFromParent(); in fold_sincos()
1360 CI->replaceAllUsesWith(Call); in fold_sincos()
1362 CI->eraseFromParent(); in fold_sincos()
1367 bool AMDGPULibCalls::fold_wavefrontsize(CallInst *CI, IRBuilder<> &B) { in fold_wavefrontsize() argument
1378 Function *F = CI->getParent()->getParent(); in fold_wavefrontsize()
1382 LLVM_DEBUG(errs() << "AMDIC: fold_wavefrontsize (" << *CI << ") with " in fold_wavefrontsize()
1385 CI->replaceAllUsesWith(ConstantInt::get(B.getInt32Ty(), N)); in fold_wavefrontsize()
1386 CI->eraseFromParent(); in fold_wavefrontsize()
1658 LLVMContext &context = CI->getParent()->getParent()->getContext(); in evaluateCall()
1661 nval0 = ConstantFP::get(CI->getType(), DVal0[0]); in evaluateCall()
1663 nval1 = ConstantFP::get(CI->getType(), DVal1[0]); in evaluateCall()
1720 CallInst *CI = dyn_cast<CallInst>(I); in runOnFunction() local
1723 if (!CI || isa<DbgInfoIntrinsic>(CI) || CI->isLifetimeStartOrEnd()) in runOnFunction()
1727 Function *Callee = CI->getCalledFunction(); in runOnFunction()
1730 LLVM_DEBUG(dbgs() << "AMDIC: try folding " << *CI << "\n"; in runOnFunction()
1732 if(Simplifier.fold(CI, AA)) in runOnFunction()
1753 CallInst *CI = dyn_cast<CallInst>(I); in run() local
1756 if (!CI || isa<DbgInfoIntrinsic>(CI) || CI->isLifetimeStartOrEnd()) in run()
1760 Function *Callee = CI->getCalledFunction(); in run()
1764 LLVM_DEBUG(dbgs() << "AMDIC: try folding " << *CI << "\n"; in run()
1766 if (Simplifier.fold(CI, AA)) in run()
1781 CallInst *CI = dyn_cast<CallInst>(I); in runOnFunction() local
1783 if (!CI) continue; in runOnFunction()
1786 Function *Callee = CI->getCalledFunction(); in runOnFunction()
1789 if(Simplifier.useNative(CI)) in runOnFunction()
1808 CallInst *CI = dyn_cast<CallInst>(I); in run() local
1810 if (!CI) in run()
1814 Function *Callee = CI->getCalledFunction(); in run()
1818 if (Simplifier.useNative(CI)) in run()