Lines Matching refs:Constant

45 static Constant *BitCastConstantVector(Constant *CV, VectorType *DstTy) {  in BitCastConstantVector()
47 if (CV->isAllOnesValue()) return Constant::getAllOnesValue(DstTy); in BitCastConstantVector()
48 if (CV->isNullValue()) return Constant::getNullValue(DstTy); in BitCastConstantVector()
64 if (Constant *Splat = CV->getSplatValue()) { in BitCastConstantVector()
69 SmallVector<Constant*, 16> Result; in BitCastConstantVector()
72 Constant *C = in BitCastConstantVector()
111 static Constant *FoldBitCast(Constant *V, Type *DestTy) { in FoldBitCast()
125 Constant::getNullValue(Type::getInt32Ty(DPTy->getContext())); in FoldBitCast()
149 return Constant::getNullValue(DestTy); in FoldBitCast()
215 static Constant *ExtractConstantBytes(Constant *C, unsigned ByteStart, in ExtractConstantBytes()
242 Constant *RHS = ExtractConstantBytes(CE->getOperand(1), ByteStart,ByteSize); in ExtractConstantBytes()
251 Constant *LHS = ExtractConstantBytes(CE->getOperand(0), ByteStart,ByteSize); in ExtractConstantBytes()
257 Constant *RHS = ExtractConstantBytes(CE->getOperand(1), ByteStart,ByteSize); in ExtractConstantBytes()
265 Constant *LHS = ExtractConstantBytes(CE->getOperand(0), ByteStart,ByteSize); in ExtractConstantBytes()
282 return Constant::getNullValue( in ExtractConstantBytes()
305 return Constant::getNullValue( in ExtractConstantBytes()
322 return Constant::getNullValue(IntegerType::get(CE->getContext(), in ExtractConstantBytes()
338 Constant *Res = CE->getOperand(0); in ExtractConstantBytes()
352 Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V, in ConstantFoldCastInstruction()
363 return Constant::getNullValue(DestTy); in ConstantFoldCastInstruction()
369 return Constant::getNullValue(DestTy); in ConstantFoldCastInstruction()
413 if (Constant *Splat = V->getSplatValue()) { in ConstantFoldCastInstruction()
418 SmallVector<Constant *, 16> res; in ConstantFoldCastInstruction()
423 Constant *C = in ConstantFoldCastInstruction()
517 if (Constant *Res = ExtractConstantBytes(V, 0, DestBitWidth / 8)) in ConstantFoldCastInstruction()
529 Constant *llvm::ConstantFoldSelectInstruction(Constant *Cond, in ConstantFoldSelectInstruction()
530 Constant *V1, Constant *V2) { in ConstantFoldSelectInstruction()
538 SmallVector<Constant*, 16> Result; in ConstantFoldSelectInstruction()
541 Constant *V; in ConstantFoldSelectInstruction()
542 Constant *V1Element = ConstantExpr::getExtractElement(V1, in ConstantFoldSelectInstruction()
544 Constant *V2Element = ConstantExpr::getExtractElement(V2, in ConstantFoldSelectInstruction()
546 auto *Cond = cast<Constant>(CondV->getOperand(i)); in ConstantFoldSelectInstruction()
582 auto NotPoison = [](Constant *C) { in ConstantFoldSelectInstruction()
618 Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val, in ConstantFoldExtractElementInstruction()
619 Constant *Idx) { in ConstantFoldExtractElementInstruction()
644 SmallVector<Constant *, 8> Ops; in ConstantFoldExtractElementInstruction()
647 Constant *Op = CE->getOperand(i); in ConstantFoldExtractElementInstruction()
649 Constant *ScalarOp = ConstantExpr::getExtractElement(Op, Idx); in ConstantFoldExtractElementInstruction()
672 if (Constant *SplatVal = Val->getSplatValue()) in ConstantFoldExtractElementInstruction()
679 Constant *llvm::ConstantFoldInsertElementInstruction(Constant *Val, in ConstantFoldInsertElementInstruction()
680 Constant *Elt, in ConstantFoldInsertElementInstruction()
681 Constant *Idx) { in ConstantFoldInsertElementInstruction()
699 SmallVector<Constant*, 16> Result; in ConstantFoldInsertElementInstruction()
709 Constant *C = ConstantExpr::getExtractElement(Val, ConstantInt::get(Ty, i)); in ConstantFoldInsertElementInstruction()
716 Constant *llvm::ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, in ConstantFoldShuffleVectorInstruction()
734 Constant *Elt = in ConstantFoldShuffleVectorInstruction()
746 SmallVector<Constant*, 32> Result; in ConstantFoldShuffleVectorInstruction()
753 Constant *InElt; in ConstantFoldShuffleVectorInstruction()
771 Constant *llvm::ConstantFoldExtractValueInstruction(Constant *Agg, in ConstantFoldExtractValueInstruction()
777 if (Constant *C = Agg->getAggregateElement(Idxs[0])) in ConstantFoldExtractValueInstruction()
783 Constant *llvm::ConstantFoldInsertValueInstruction(Constant *Agg, in ConstantFoldInsertValueInstruction()
784 Constant *Val, in ConstantFoldInsertValueInstruction()
796 SmallVector<Constant*, 32> Result; in ConstantFoldInsertValueInstruction()
798 Constant *C = Agg->getAggregateElement(i); in ConstantFoldInsertValueInstruction()
812 Constant *llvm::ConstantFoldUnaryInstruction(unsigned Opcode, Constant *C) { in ConstantFoldUnaryInstruction()
847 if (Constant *Splat = C->getSplatValue()) { in ConstantFoldUnaryInstruction()
848 Constant *Elt = ConstantExpr::get(Opcode, Splat); in ConstantFoldUnaryInstruction()
853 SmallVector<Constant *, 16> Result; in ConstantFoldUnaryInstruction()
855 Constant *ExtractIdx = ConstantInt::get(Ty, i); in ConstantFoldUnaryInstruction()
856 Constant *Elt = ConstantExpr::getExtractElement(C, ExtractIdx); in ConstantFoldUnaryInstruction()
868 Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1, in ConstantFoldBinaryInstruction()
869 Constant *C2) { in ConstantFoldBinaryInstruction()
877 Constant *Identity = ConstantExpr::getBinOpIdentity(Opcode, C1->getType()); in ConstantFoldBinaryInstruction()
901 return Constant::getNullValue(C1->getType()); in ConstantFoldBinaryInstruction()
909 return Constant::getNullValue(C1->getType()); // undef & X -> 0 in ConstantFoldBinaryInstruction()
921 return Constant::getNullValue(C1->getType()); in ConstantFoldBinaryInstruction()
933 return Constant::getNullValue(C1->getType()); in ConstantFoldBinaryInstruction()
941 return Constant::getNullValue(C1->getType()); in ConstantFoldBinaryInstruction()
945 return Constant::getAllOnesValue(C1->getType()); // undef | X -> ~0 in ConstantFoldBinaryInstruction()
954 return Constant::getNullValue(C1->getType()); in ConstantFoldBinaryInstruction()
964 return Constant::getNullValue(C1->getType()); in ConstantFoldBinaryInstruction()
973 return Constant::getNullValue(C1->getType()); in ConstantFoldBinaryInstruction()
1026 return Constant::getNullValue(CI2->getType()); // X % 1 == 0 in ConstantFoldBinaryInstruction()
1083 return Constant::getNullValue(CI2->getType()); in ConstantFoldBinaryInstruction()
1213 if (Constant *C2Splat = C2->getSplatValue()) { in ConstantFoldBinaryInstruction()
1216 if (Constant *C1Splat = C1->getSplatValue()) { in ConstantFoldBinaryInstruction()
1225 SmallVector<Constant*, 16> Result; in ConstantFoldBinaryInstruction()
1228 Constant *ExtractIdx = ConstantInt::get(Ty, i); in ConstantFoldBinaryInstruction()
1229 Constant *LHS = ConstantExpr::getExtractElement(C1, ExtractIdx); in ConstantFoldBinaryInstruction()
1230 Constant *RHS = ConstantExpr::getExtractElement(C2, ExtractIdx); in ConstantFoldBinaryInstruction()
1251 Constant *T = ConstantExpr::get(Opcode, CE1->getOperand(1), C2); in ConstantFoldBinaryInstruction()
1319 static int IdxCompare(Constant *C1, Constant *C2, Type *ElTy) { in IdxCompare()
1363 static FCmpInst::Predicate evaluateFCmpRelation(Constant *V1, Constant *V2) { in evaluateFCmpRelation()
1452 static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2, in evaluateICmpRelation()
1544 Constant *CE1Op0 = CE1->getOperand(0); in evaluateICmpRelation()
1575 Constant::getNullValue(CE1Op0->getType()), in evaluateICmpRelation()
1627 Constant *CE2Op0 = CE2->getOperand(0); in evaluateICmpRelation()
1700 Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, in ConstantFoldCompareInstruction()
1701 Constant *C1, Constant *C2) { in ConstantFoldCompareInstruction()
1711 return Constant::getNullValue(ResultTy); in ConstantFoldCompareInstruction()
1714 return Constant::getAllOnesValue(ResultTy); in ConstantFoldCompareInstruction()
1769 return Constant::getAllOnesValue(ResultTy); in ConstantFoldCompareInstruction()
1772 return Constant::getNullValue(ResultTy); in ConstantFoldCompareInstruction()
1811 case FCmpInst::FCMP_FALSE: return Constant::getNullValue(ResultTy); in ConstantFoldCompareInstruction()
1812 case FCmpInst::FCMP_TRUE: return Constant::getAllOnesValue(ResultTy); in ConstantFoldCompareInstruction()
1851 if (Constant *C1Splat = C1->getSplatValue()) in ConstantFoldCompareInstruction()
1852 if (Constant *C2Splat = C2->getSplatValue()) in ConstantFoldCompareInstruction()
1864 SmallVector<Constant*, 4> ResElts; in ConstantFoldCompareInstruction()
1869 Constant *C1E = in ConstantFoldCompareInstruction()
1871 Constant *C2E = in ConstantFoldCompareInstruction()
2023 Constant *CE2Op0 = CE2->getOperand(0); in ConstantFoldCompareInstruction()
2027 Constant *Inverse = ConstantExpr::getBitCast(C1, CE2Op0->getType()); in ConstantFoldCompareInstruction()
2038 Constant *CE1Op0 = CE1->getOperand(0); in ConstantFoldCompareInstruction()
2039 Constant *CE1Inverse = ConstantExpr::getTrunc(CE1, CE1Op0->getType()); in ConstantFoldCompareInstruction()
2042 Constant *C2Inverse = ConstantExpr::getTrunc(C2, CE1Op0->getType()); in ConstantFoldCompareInstruction()
2069 if (cast<Constant>(Idxs[0])->isNullValue()) return true; in isInBoundsIndices()
2084 if (!cast<Constant>(Idxs[i])->isNullValue()) in isInBoundsIndices()
2109 static Constant *foldGEPOfGEP(GEPOperator *GEP, Type *PointeeTy, bool InBounds, in foldGEPOfGEP()
2114 Constant *Idx0 = cast<Constant>(Idxs[0]); in foldGEPOfGEP()
2122 GEP->getSourceElementType(), cast<Constant>(GEP->getPointerOperand()), in foldGEPOfGEP()
2159 auto *LastIdx = cast<Constant>(GEP->getOperand(GEP->getNumOperands()-1)); in foldGEPOfGEP()
2193 GEP->getSourceElementType(), cast<Constant>(GEP->getPointerOperand()), in foldGEPOfGEP()
2197 Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C, in ConstantFoldGetElementPtr()
2213 Constant *Idx0 = cast<Constant>(Idxs[0]); in ConstantFoldGetElementPtr()
2224 !cast<Constant>(Idxs[i])->isNullValue()) { in ConstantFoldGetElementPtr()
2250 return Constant::getNullValue(GEPTy); in ConstantFoldGetElementPtr()
2256 if (Constant *C = foldGEPOfGEP(GEP, PointeeTy, InBounds, Idxs)) in ConstantFoldGetElementPtr()
2281 (Constant *)CE->getOperand(0), in ConstantFoldGetElementPtr()
2290 SmallVector<Constant *, 8> NewIdxs; in ConstantFoldGetElementPtr()
2361 Constant *CurrIdx = cast<Constant>(Idxs[i]); in ConstantFoldGetElementPtr()
2363 NewIdxs[i - 1] ? NewIdxs[i - 1] : cast<Constant>(Idxs[i - 1]); in ConstantFoldGetElementPtr()
2376 Constant *Factor = in ConstantFoldGetElementPtr()
2387 Constant *Div = ConstantExpr::getSDiv(CurrIdx, Factor); in ConstantFoldGetElementPtr()
2416 if (!NewIdxs[i]) NewIdxs[i] = cast<Constant>(Idxs[i]); in ConstantFoldGetElementPtr()