Lines Matching defs:LVI
96 static Constant *getConstantAt(Value *V, Instruction *At, LazyValueInfo *LVI) {
97 if (Constant *C = LVI->getConstant(V, At))
100 // TODO: The following really should be sunk inside LVI's core algorithm, or
111 return LVI->getPredicateAt(C->getPredicate(), Op0, Op1, At,
115 static bool processSelect(SelectInst *S, LazyValueInfo *LVI) {
124 C = LVI->getConstantOnEdge(S->getCondition(), PN->getIncomingBlock(U),
127 C = getConstantAt(S->getCondition(), I, LVI);
155 static bool simplifyCommonValuePhi(PHINode *P, LazyValueInfo *LVI,
188 if (C != LVI->getConstantOnEdge(CommonValue, IncomingBB, ToBB, P))
192 // LVI only guarantees that the value matches a certain constant if the value
206 static Value *getValueOnEdge(LazyValueInfo *LVI, Value *Incoming,
209 if (Constant *C = LVI->getConstantOnEdge(Incoming, From, To, CxtI))
213 // LVI can tells us the value. In that case replace the incoming value with
220 // Once LVI learns to handle vector types, we could also add support
224 if (Constant *C = LVI->getConstantOnEdge(Condition, From, To, CxtI)) {
232 // Look if the select has a constant but LVI tells us that the incoming
240 LVI->getPredicateOnEdge(ICmpInst::ICMP_EQ, SI, C, From, To, CxtI));
248 LVI->getPredicateOnEdge(ICmpInst::ICMP_EQ, SI, C, From, To, CxtI));
255 static bool processPHI(PHINode *P, LazyValueInfo *LVI, DominatorTree *DT,
264 Value *V = getValueOnEdge(LVI, Incoming, P->getIncomingBlock(i), BB, P);
278 Changed = simplifyCommonValuePhi(P, LVI, DT);
286 static bool processICmp(ICmpInst *Cmp, LazyValueInfo *LVI) {
296 ConstantRange CR1 = LVI->getConstantRangeAtUse(Cmp->getOperandUse(0),
298 CR2 = LVI->getConstantRangeAtUse(Cmp->getOperandUse(1),
326 static bool constantFoldCmp(CmpInst *Cmp, LazyValueInfo *LVI) {
329 Constant *Res = LVI->getPredicateAt(Cmp->getPredicate(), Op0, Op1, Cmp,
340 static bool processCmp(CmpInst *Cmp, LazyValueInfo *LVI) {
341 if (constantFoldCmp(Cmp, LVI))
345 if (processICmp(ICmp, LVI))
358 static bool processSwitch(SwitchInst *I, LazyValueInfo *LVI,
378 LVI->getPredicateAt(CmpInst::ICMP_EQ, Cond, Case, I,
416 ConstantRange CR = LVI->getConstantRangeAtUse(I->getOperandUse(0),
447 static bool willNotOverflow(BinaryOpIntrinsic *BO, LazyValueInfo *LVI) {
449 LVI->getConstantRangeAtUse(BO->getOperandUse(0), /*UndefAllowed*/ false);
451 LVI->getConstantRangeAtUse(BO->getOperandUse(1), /*UndefAllowed*/ false);
504 static bool processBinOp(BinaryOperator *BinOp, LazyValueInfo *LVI);
509 static bool processAbsIntrinsic(IntrinsicInst *II, LazyValueInfo *LVI) {
513 ConstantRange Range = LVI->getConstantRangeAtUse(
535 processBinOp(BO, LVI);
551 static bool processCmpIntrinsic(CmpIntrinsic *CI, LazyValueInfo *LVI) {
553 LVI->getConstantRangeAtUse(CI->getOperandUse(0), /*UndefAllowed*/ false);
555 LVI->getConstantRangeAtUse(CI->getOperandUse(1), /*UndefAllowed*/ false);
581 static bool processMinMaxIntrinsic(MinMaxIntrinsic *MM, LazyValueInfo *LVI) {
583 ConstantRange LHS_CR = LVI->getConstantRangeAtUse(MM->getOperandUse(0),
585 ConstantRange RHS_CR = LVI->getConstantRangeAtUse(MM->getOperandUse(1),
617 static bool processOverflowIntrinsic(WithOverflowInst *WO, LazyValueInfo *LVI) {
638 processBinOp(BO, LVI);
643 static bool processSaturatingInst(SaturatingInst *SI, LazyValueInfo *LVI) {
658 processBinOp(BO, LVI);
664 static bool processCallSite(CallBase &CB, LazyValueInfo *LVI) {
667 return processAbsIntrinsic(&cast<IntrinsicInst>(CB), LVI);
671 return processCmpIntrinsic(CI, LVI);
675 return processMinMaxIntrinsic(MM, LVI);
679 if (willNotOverflow(WO, LVI))
680 return processOverflowIntrinsic(WO, LVI);
684 if (willNotOverflow(SI, LVI))
685 return processSaturatingInst(SI, LVI);
696 // we may have a conditional fact with which LVI can fold.
704 Constant *C = LVI->getConstant(V, &CB);
721 if (auto *Res = dyn_cast_or_null<ConstantInt>(LVI->getPredicateAt(
920 static bool processUDivOrURem(BinaryOperator *Instr, LazyValueInfo *LVI) {
923 ConstantRange XCR = LVI->getConstantRangeAtUse(Instr->getOperandUse(0),
926 ConstantRange YCR = LVI->getConstantRangeAtUse(Instr->getOperandUse(1),
935 const ConstantRange &RCR, LazyValueInfo *LVI) {
983 processUDivOrURem(URem, LVI);
994 const ConstantRange &RCR, LazyValueInfo *LVI) {
1045 processUDivOrURem(UDiv, LVI);
1050 static bool processSDivOrSRem(BinaryOperator *Instr, LazyValueInfo *LVI) {
1054 LVI->getConstantRangeAtUse(Instr->getOperandUse(0), /*AllowUndef*/ false);
1057 LVI->getConstantRangeAtUse(Instr->getOperandUse(1), /*AlloweUndef*/ true);
1059 if (processSDiv(Instr, LCR, RCR, LVI))
1063 if (processSRem(Instr, LCR, RCR, LVI))
1070 static bool processAShr(BinaryOperator *SDI, LazyValueInfo *LVI) {
1072 LVI->getConstantRangeAtUse(SDI->getOperandUse(0), /*UndefAllowed*/ false);
1099 static bool processSExt(SExtInst *SDI, LazyValueInfo *LVI) {
1101 if (!LVI->getConstantRangeAtUse(Base, /*UndefAllowed*/ false)
1117 static bool processPossibleNonNeg(PossiblyNonNegInst *I, LazyValueInfo *LVI) {
1122 if (!LVI->getConstantRangeAtUse(Base, /*UndefAllowed*/ false)
1132 static bool processZExt(ZExtInst *ZExt, LazyValueInfo *LVI) {
1133 return processPossibleNonNeg(cast<PossiblyNonNegInst>(ZExt), LVI);
1136 static bool processUIToFP(UIToFPInst *UIToFP, LazyValueInfo *LVI) {
1137 return processPossibleNonNeg(cast<PossiblyNonNegInst>(UIToFP), LVI);
1140 static bool processSIToFP(SIToFPInst *SIToFP, LazyValueInfo *LVI) {
1142 if (!LVI->getConstantRangeAtUse(Base, /*UndefAllowed*/ false)
1158 static bool processBinOp(BinaryOperator *BinOp, LazyValueInfo *LVI) {
1167 ConstantRange LRange = LVI->getConstantRangeAtUse(BinOp->getOperandUse(0),
1169 ConstantRange RRange = LVI->getConstantRangeAtUse(BinOp->getOperandUse(1),
1192 static bool processAnd(BinaryOperator *BinOp, LazyValueInfo *LVI) {
1205 LVI->getConstantRangeAtUse(LHS, /*UndefAllowed=*/false);
1215 static bool runImpl(Function &F, LazyValueInfo *LVI, DominatorTree *DT,
1233 BBChanged |= processSelect(cast<SelectInst>(&II), LVI);
1236 BBChanged |= processPHI(cast<PHINode>(&II), LVI, DT, SQ);
1240 BBChanged |= processCmp(cast<CmpInst>(&II), LVI);
1244 BBChanged |= processCallSite(cast<CallBase>(II), LVI);
1248 BBChanged |= processSDivOrSRem(cast<BinaryOperator>(&II), LVI);
1252 BBChanged |= processUDivOrURem(cast<BinaryOperator>(&II), LVI);
1255 BBChanged |= processAShr(cast<BinaryOperator>(&II), LVI);
1258 BBChanged |= processSExt(cast<SExtInst>(&II), LVI);
1261 BBChanged |= processZExt(cast<ZExtInst>(&II), LVI);
1264 BBChanged |= processUIToFP(cast<UIToFPInst>(&II), LVI);
1267 BBChanged |= processSIToFP(cast<SIToFPInst>(&II), LVI);
1273 BBChanged |= processBinOp(cast<BinaryOperator>(&II), LVI);
1276 BBChanged |= processAnd(cast<BinaryOperator>(&II), LVI);
1284 BBChanged |= processSwitch(cast<SwitchInst>(Term), LVI, DT);
1295 RetRange->unionWith(LVI->getConstantRange(RetVal, RI,
1299 if (auto *C = getConstantAt(RetVal, RI, LVI)) {
1327 LazyValueInfo *LVI = &AM.getResult<LazyValueAnalysis>(F);
1330 bool Changed = runImpl(F, LVI, DT, getBestSimplifyQuery(AM, F));
1346 // Keeping LVI alive is expensive, both because it uses a lot of memory, and
1347 // because invalidating values in LVI is expensive. While CVP does preserve
1348 // LVI, we know that passes after JumpThreading+CVP will not need the result