Lines Matching defs:CI
57 void visitCallInst(CallInst &CI) { checkCandidate(CI); }
60 for (auto &CI : WorkList) {
61 LLVM_DEBUG(dbgs() << "CDCE calls: " << CI->getCalledFunction()->getName()
63 if (perform(CI)) {
72 bool perform(CallInst *CI);
73 void checkCandidate(CallInst &CI);
74 void shrinkWrapCI(CallInst *CI, Value *Cond);
75 bool performCallDomainErrorOnly(CallInst *CI, const LibFunc &Func);
76 bool performCallErrors(CallInst *CI, const LibFunc &Func);
77 bool performCallRangeErrorOnly(CallInst *CI, const LibFunc &Func);
78 Value *generateOneRangeCond(CallInst *CI, const LibFunc &Func);
79 Value *generateTwoRangeCond(CallInst *CI, const LibFunc &Func);
80 Value *generateCondForPow(CallInst *CI, const LibFunc &Func);
83 Value *createOrCond(CallInst *CI, Value *Arg, CmpInst::Predicate Cmp,
86 IRBuilder<> BBBuilder(CI);
93 Value *createOrCond(CallInst *CI, CmpInst::Predicate Cmp, float Val,
95 Value *Arg = CI->getArgOperand(0);
96 return createOrCond(CI, Arg, Cmp, Val, Arg, Cmp2, Val2);
111 Value *createCond(CallInst *CI, Value *Arg, CmpInst::Predicate Cmp,
113 IRBuilder<> BBBuilder(CI);
118 Value *createCond(CallInst *CI, CmpInst::Predicate Cmp, float Val) {
119 Value *Arg = CI->getArgOperand(0);
120 return createCond(CI, Arg, Cmp, Val);
130 bool LibCallsShrinkWrap::performCallDomainErrorOnly(CallInst *CI,
143 Cond = createOrCond(CI, CmpInst::FCMP_OLT, -1.0f, CmpInst::FCMP_OGT, 1.0f);
154 Cond = createOrCond(CI, CmpInst::FCMP_OEQ, INFINITY, CmpInst::FCMP_OEQ,
163 Cond = createCond(CI, CmpInst::FCMP_OLT, 1.0f);
171 Cond = createCond(CI, CmpInst::FCMP_OLT, 0.0f);
177 shrinkWrapCI(CI, Cond);
182 bool LibCallsShrinkWrap::performCallRangeErrorOnly(CallInst *CI,
202 Cond = generateTwoRangeCond(CI, Func);
209 Cond = generateOneRangeCond(CI, Func);
215 shrinkWrapCI(CI, Cond);
220 bool LibCallsShrinkWrap::performCallErrors(CallInst *CI,
232 Cond = createOrCond(CI, CmpInst::FCMP_OLE, -1.0f, CmpInst::FCMP_OGE, 1.0f);
251 Cond = createCond(CI, CmpInst::FCMP_OLE, 0.0f);
261 Cond = createCond(CI, CmpInst::FCMP_OLE, -1.0f);
269 Cond = generateCondForPow(CI, Func);
278 shrinkWrapCI(CI, Cond);
282 // Checks if CI is a candidate for shrinkwrapping and put it into work list if
284 void LibCallsShrinkWrap::checkCandidate(CallInst &CI) {
285 if (CI.isNoBuiltin())
291 if (!CI.use_empty())
295 Function *Callee = CI.getCalledFunction();
301 if (CI.arg_empty())
304 Type *ArgType = CI.getArgOperand(0)->getType();
309 WorkList.push_back(&CI);
313 Value *LibCallsShrinkWrap::generateOneRangeCond(CallInst *CI,
331 return createCond(CI, CmpInst::FCMP_OGT, UpperBound);
335 Value *LibCallsShrinkWrap::generateTwoRangeCond(CallInst *CI,
395 return createOrCond(CI, CmpInst::FCMP_OGT, UpperBound, CmpInst::FCMP_OLT,
414 Value *LibCallsShrinkWrap::generateCondForPow(CallInst *CI,
422 Value *Base = CI->getArgOperand(0);
423 Value *Exp = CI->getArgOperand(1);
434 return createCond(CI, Exp, CmpInst::FCMP_OGT, 127.0f);
459 return createOrCond(CI, Base, CmpInst::FCMP_OLE, 0.0f, Exp,
467 void LibCallsShrinkWrap::shrinkWrapCI(CallInst *CI, Value *Cond) {
470 MDBuilder(CI->getContext()).createUnlikelyBranchWeights();
473 SplitBlockAndInsertIfThen(Cond, CI, false, BranchWeights, &DTU);
479 CI->removeFromParent();
480 CI->insertInto(CallBB, CallBB->getFirstInsertionPt());
487 bool LibCallsShrinkWrap::perform(CallInst *CI) {
489 Function *Callee = CI->getCalledFunction();
494 if (performCallDomainErrorOnly(CI, Func) || performCallRangeErrorOnly(CI, Func))
496 return performCallErrors(CI, Func);