Home | History | Annotate | Download | only in Utils

Lines Matching refs:Value

61 /// value is equal or not-equal to zero.
62 static bool isOnlyUsedInZeroEqualityComparison(Value *V) {
77 static bool isOnlyUsedInEqualityComparison(Value *V, Value *With) {
194 Value *LibCallSimplifier::optimizeStrCat(CallInst *CI, IRBuilder<> &B) {
205 Value *Dst = CI->getArgOperand(0);
206 Value *Src = CI->getArgOperand(1);
221 Value *LibCallSimplifier::emitStrLenMemCpy(Value *Src, Value *Dst, uint64_t Len,
225 Value *DstLen = EmitStrLen(Dst, B, DL, TLI);
232 Value *CpyDst = B.CreateGEP(B.getInt8Ty(), Dst, DstLen, "endptr");
242 Value *LibCallSimplifier::optimizeStrNCat(CallInst *CI, IRBuilder<> &B) {
253 Value *Dst = CI->getArgOperand(0);
254 Value *Src = CI->getArgOperand(1);
284 Value *LibCallSimplifier::optimizeStrChr(CallInst *CI, IRBuilder<> &B) {
293 Value *SrcStr = CI->getArgOperand(0);
329 Value *LibCallSimplifier::optimizeStrRChr(CallInst *CI, IRBuilder<> &B) {
338 Value *SrcStr = CI->getArgOperand(0);
364 Value *LibCallSimplifier::optimizeStrCmp(CallInst *CI, IRBuilder<> &B) {
373 Value *Str1P = CI->getArgOperand(0), *Str2P = CI->getArgOperand(1);
405 Value *LibCallSimplifier::optimizeStrNCmp(CallInst *CI, IRBuilder<> &B) {
415 Value *Str1P = CI->getArgOperand(0), *Str2P = CI->getArgOperand(1);
453 Value
459 Value *Dst = CI->getArgOperand(0), *Src = CI->getArgOperand(1);
475 Value *LibCallSimplifier::optimizeStpCpy(CallInst *CI, IRBuilder<> &B) {
480 Value *Dst = CI->getArgOperand(0), *Src = CI->getArgOperand(1);
482 Value *StrLen = EmitStrLen(Src, B, DL, TLI);
492 Value *LenV = ConstantInt::get(DL.getIntPtrType(PT), Len);
493 Value *DstEnd =
502 Value *LibCallSimplifier::optimizeStrNCpy(CallInst *CI, IRBuilder<> &B) {
507 Value *Dst = CI->getArgOperand(0);
508 Value *Src = CI->getArgOperand(1);
509 Value *LenOp = CI->getArgOperand(2);
543 Value *LibCallSimplifier::optimizeStrLen(CallInst *CI, IRBuilder<> &B) {
550 Value *Src = CI->getArgOperand(0);
579 Value *LibCallSimplifier::optimizeStrPBrk(CallInst *CI, IRBuilder<> &B) {
612 Value *LibCallSimplifier::optimizeStrTo(CallInst *CI, IRBuilder<> &B) {
620 Value *EndPtr = CI->getArgOperand(1);
630 Value *LibCallSimplifier::optimizeStrSpn(CallInst *CI, IRBuilder<> &B) {
658 Value *LibCallSimplifier::optimizeStrCSpn(CallInst *CI, IRBuilder<> &B) {
689 Value *LibCallSimplifier::optimizeStrStr(CallInst *CI, IRBuilder<> &B) {
703 Value *StrLen = EmitStrLen(CI->getArgOperand(1), B, DL, TLI);
706 Value *StrNCmp = EmitStrNCmp(CI->getArgOperand(0), CI->getArgOperand(1),
712 Value *Cmp =
737 Value *Result = CastToCStr(CI->getArgOperand(0), B);
744 Value *StrChr = EmitStrChr(CI->getArgOperand(0), ToFindStr[0], B, TLI);
750 Value *LibCallSimplifier::optimizeMemChr(CallInst *CI, IRBuilder<> &B) {
759 Value *SrcStr = CI->getArgOperand(0);
779 // when the return value is only checked against null.
807 Value *BitfieldC = B.getInt(Bitfield);
810 Value *C = B.CreateZExtOrTrunc(CI->getArgOperand(1), BitfieldC->getType());
811 Value *Bounds = B.CreateICmp(ICmpInst::ICMP_ULT, C, B.getIntN(Width, Width),
815 Value *Shl = B.CreateShl(B.getIntN(Width, 1ULL), C);
816 Value *Bits = B.CreateIsNotNull(B.CreateAnd(Shl, BitfieldC), "memchr.bits");
836 Value *LibCallSimplifier::optimizeMemCmp(CallInst *CI, IRBuilder<> &B) {
844 Value *LHS = CI->getArgOperand(0), *RHS = CI->getArgOperand(1);
860 Value *LHSV = B.CreateZExt(B.CreateLoad(CastToCStr(LHS, B), "lhsc"),
862 Value *RHSV = B.CreateZExt(B.CreateLoad(CastToCStr(RHS, B), "rhsc"),
881 Value *LHSV = B.CreateLoad(B.CreateBitCast(LHS, LHSPtrTy, "lhsc"), "lhsv");
882 Value *RHSV = B.CreateLoad(B.CreateBitCast(RHS, RHSPtrTy, "rhsc"), "rhsv");
909 Value *LibCallSimplifier::optimizeMemCpy(CallInst *CI, IRBuilder<> &B) {
921 Value *LibCallSimplifier::optimizeMemMove(CallInst *CI, IRBuilder<> &B) {
933 Value *LibCallSimplifier::optimizeMemSet(CallInst *CI, IRBuilder<> &B) {
940 Value *Val = B.CreateIntCast(CI->getArgOperand(1), B.getInt8Ty(), false);
951 /// value to something bigger, simply return the operand.
954 static Value *valueHasFloatPrecision(Value *Val) {
956 Value *Op = Cast->getOperand(0);
974 Value *LibCallSimplifier::optimizeUnaryDoubleFP(CallInst *CI, IRBuilder<> &B,
992 Value *V = valueHasFloatPrecision(CI->getArgOperand(0));
1011 Value *LibCallSimplifier::optimizeBinaryDoubleFP(CallInst *CI, IRBuilder<> &B) {
1023 Value *V1 = valueHasFloatPrecision(CI->getArgOperand(0));
1026 Value *V2 = valueHasFloatPrecision(CI->getArgOperand(1));
1033 Value *V = EmitBinaryFloatFnCall(V1, V2, Callee->getName(), B,
1038 Value *LibCallSimplifier::optimizeCos(CallInst *CI, IRBuilder<> &B) {
1040 Value *Ret = nullptr;
1053 Value *Op1 = CI->getArgOperand(0);
1061 static Value *getPow(Value *InnerChain[33], unsigned Exp, IRBuilder<> &B) {
1086 Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) {
1088 Value *Ret = nullptr;
1101 Value *Op1 = CI->getArgOperand(0), *Op2 = CI->getArgOperand(1);
1168 Value *Inf = ConstantFP::getInfinity(CI->getType());
1169 Value *NegInf = ConstantFP::getInfinity(CI->getType(), true);
1170 Value *Sqrt = EmitUnaryFloatFnCall(Op1, "sqrt", B, Callee->getAttributes());
1171 Value *FAbs =
1173 Value *FCmp = B.CreateFCmpOEQ(Op1, NegInf);
1174 Value *Sel = B.CreateSelect(FCmp, Inf, FAbs);
1195 Value *InnerChain[33] = {nullptr};
1203 Value *FMul = getPow(InnerChain, V.convertToDouble(), B);
1213 Value *LibCallSimplifier::optimizeExp2(CallInst *CI, IRBuilder<> &B) {
1216 Value *Ret = nullptr;
1228 Value *Op = CI->getArgOperand(0);
1238 Value *LdExpArg = nullptr;
1253 Value *Callee =
1266 Value *LibCallSimplifier::optimizeFabs(CallInst *CI, IRBuilder<> &B) {
1268 Value *Ret = nullptr;
1279 Value *Op = CI->getArgOperand(0);
1281 // Fold fabs(x * x) -> x * x; any squared FP value must already be positive.
1289 Value *LibCallSimplifier::optimizeFMinFMax(CallInst *CI, IRBuilder<> &B) {
1296 Value *Ret = optimizeBinaryDoubleFP(CI, B);
1331 Value *Op0 = CI->getArgOperand(0);
1332 Value *Op1 = CI->getArgOperand(1);
1333 Value *Cmp = Callee->getName().startswith("fmin") ?
1338 Value *LibCallSimplifier::optimizeLog(CallInst *CI, IRBuilder<> &B) {
1340 Value *Ret = nullptr;
1354 Value *Op1 = CI->getArgOperand(0);
1388 Value *LibCallSimplifier::optimizeSqrt(CallInst *CI, IRBuilder<> &B) {
1391 Value *Ret = nullptr;
1398 Value *Op = CI->getArgOperand(0);
1404 Value *Op0 = I->getOperand(0);
1405 Value *Op1 = I->getOperand(1);
1406 Value *RepeatOp = nullptr;
1407 Value *OtherOp = nullptr;
1417 Value *OtherMul0, *OtherMul1;
1438 Value *Fabs = Intrinsic::getDeclaration(M, Intrinsic::fabs, ArgType);
1439 Value *FabsCall = B.CreateCall(Fabs, RepeatOp, "fabs");
1442 // root. We then multiply that by the value that was simplified out
1444 Value *Sqrt = Intrinsic::getDeclaration(M, Intrinsic::sqrt, ArgType);
1445 Value *SqrtCall = B.CreateCall(Sqrt, OtherOp, "sqrt");
1455 Value *LibCallSimplifier::optimizeTan(CallInst *CI, IRBuilder<> &B) {
1457 Value *Ret = nullptr;
1471 Value *Op1 = CI->getArgOperand(0);
1490 static void insertSinCosCall(IRBuilder<> &B, Function *OrigCallee, Value *Arg,
1491 bool UseFloat, Value *&Sin, Value *&Cos,
1492 Value *&SinCos);
1494 Value *LibCallSimplifier::optimizeSinCosPi(CallInst *CI, IRBuilder<> &B) {
1501 Value *Arg = CI->getArgOperand(0);
1519 Value *Sin, *Cos, *SinCos;
1546 LibCallSimplifier::classifyArgUse(Value *Val, BasicBlock *BB, bool IsFloat,
1579 Value *Res) {
1584 void insertSinCosCall(IRBuilder<> &B, Function *OrigCallee, Value *Arg,
1585 bool UseFloat, Value *&Sin, Value *&Cos, Value *&SinCos) {
1606 Value *Callee = M->getOrInsertFunction(Name, OrigCallee->getAttributes(),
1643 Value *LibCallSimplifier::optimizeFFS(CallInst *CI, IRBuilder<> &B) {
1647 Value *Op = CI->getArgOperand(0);
1659 Value *F =
1661 Value *V = B.CreateCall(F, {Op, B.getTrue()}, "cttz");
1665 Value *Cond = B.CreateICmpNE(Op, Constant::getNullValue(ArgType));
1669 Value *LibCallSimplifier::optimizeAbs(CallInst *CI, IRBuilder<> &B) {
1678 Value *Op = CI->getArgOperand(0);
1679 Value *Pos =
1681 Value *Neg = B.CreateNeg(Op, "neg");
1685 Value *LibCallSimplifier::optimizeIsDigit(CallInst *CI, IRBuilder<> &B) {
1690 Value *Op = CI->getArgOperand(0);
1696 Value *LibCallSimplifier::optimizeIsAscii(CallInst *CI, IRBuilder<> &B) {
1701 Value *Op = CI->getArgOperand(0);
1706 Value *LibCallSimplifier::optimizeToAscii(CallInst *CI, IRBuilder<> &B) {
1721 Value *LibCallSimplifier::optimizeErrorReporting(CallInst *CI, IRBuilder<> &B,
1762 Value *LibCallSimplifier::optimizePrintFString(CallInst *CI, IRBuilder<> &B) {
1770 return CI->use_empty() ? (Value *)CI : ConstantInt::get(CI->getType(), 0);
1772 // Do not do any of the following transformations if the printf return value
1773 // is used, in general the printf return value is not compatible with either
1780 Value *Res = EmitPutChar(B.getInt32(FormatStr[0]), B, TLI);
1792 Value *GV = B.CreateGlobalString(FormatStr, "str");
1793 Value *NewCI = EmitPutS(GV, B, TLI);
1803 Value *Res = EmitPutChar(CI->getArgOperand(1), B, TLI);
1818 Value *LibCallSimplifier::optimizePrintF(CallInst *CI, IRBuilder<> &B) {
1827 if (Value *V = optimizePrintFString(CI, B)) {
1845 Value *LibCallSimplifier::optimizeSPrintFString(CallInst *CI, IRBuilder<> &B) {
1878 Value *V = B.CreateTrunc(CI->getArgOperand(2), B.getInt8Ty(), "char");
1879 Value *Ptr = CastToCStr(CI->getArgOperand(0), B);
1892 Value *Len = EmitStrLen(CI->getArgOperand(2), B, DL, TLI);
1895 Value *IncLen =
1905 Value *LibCallSimplifier::optimizeSPrintF(CallInst *CI, IRBuilder<> &B) {
1914 if (Value *V = optimizeSPrintFString(CI, B)) {
1932 Value *LibCallSimplifier::optimizeFPrintFString(CallInst *CI, IRBuilder<> &B) {
1941 // value is used, in general the fprintf return value is not compatible
1981 Value *LibCallSimplifier::optimizeFPrintF(CallInst *CI, IRBuilder<> &B) {
1990 if (Value *V = optimizeFPrintFString(CI, B)) {
2008 Value *LibCallSimplifier::optimizeFWrite(CallInst *CI, IRBuilder<> &B) {
2033 // This optimisation is only valid, if the return value is unused.
2035 Value *Char = B.CreateLoad(CastToCStr(CI->getArgOperand(0), B), "char");
2036 Value *NewCI = EmitFPutC(Char, CI->getArgOperand(3), B, TLI);
2043 Value *LibCallSimplifier::optimizeFPuts(CallInst *CI, IRBuilder<> &B) {
2048 // Require two pointers. Also, we can't optimize if return value is used.
2066 Value *LibCallSimplifier::optimizePuts(CallInst *CI, IRBuilder<> &B) {
2081 Value *Res = EmitPutChar(B.getInt32('\n'), B, TLI);
2099 Value *LibCallSimplifier::optimizeStringMemoryLibCall(CallInst *CI,
2165 Value *LibCallSimplifier::optimizeCall(CallInst *CI) {
2202 if (Value *SimplifiedFortifiedCI = FortifiedSimplifier.optimizeCall(CI)) {
2209 if (Value *V = optimizeStringMemoryLibCall(SimplifiedCI, TmpBuilder)) {
2224 if (Value
2341 function_ref<void(Instruction *, Value *)> Replacer)
2345 void LibCallSimplifier::replaceAllUsesWith(Instruction *I, Value *With) {
2422 Value *FortifiedLibCallSimplifier::optimizeMemCpyChk(CallInst *CI, IRBuilder<> &B) {
2436 Value *FortifiedLibCallSimplifier::optimizeMemMoveChk(CallInst *CI, IRBuilder<> &B) {
2450 Value *FortifiedLibCallSimplifier::optimizeMemSetChk(CallInst *CI, IRBuilder<> &B) {
2457 Value *Val = B.CreateIntCast(CI->getArgOperand(1), B.getInt8Ty(), false);
2464 Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI,
2474 Value *Dst = CI->getArgOperand(0), *Src = CI->getArgOperand(1),
2479 Value *StrLen = EmitStrLen(Src, B, DL, TLI);
2500 Value *LenV = ConstantInt::get(SizeTTy, Len);
2501 Value *Ret = EmitMemCpyChk(Dst, Src, LenV, ObjSize, B, DL, TLI);
2509 Value *FortifiedLibCallSimplifier::optimizeStrpNCpyChk(CallInst *CI,
2518 Value *Ret = EmitStrNCpy(CI->getArgOperand(0), CI->getArgOperand(1),
2525 Value *FortifiedLibCallSimplifier::optimizeCall(CallInst *CI) {