Lines Matching refs:SI
322 } else if (auto *SI = dyn_cast<SelectInst>(Inst)) { in collectUsersRecursive() local
323 if (!isa<Instruction>(SI->getTrueValue()) || in collectUsersRecursive()
324 !isa<Instruction>(SI->getFalseValue())) in collectUsersRecursive()
327 if (!isAvailable(cast<Instruction>(SI->getTrueValue())) || in collectUsersRecursive()
328 !isAvailable(cast<Instruction>(SI->getFalseValue()))) { in collectUsersRecursive()
332 Worklist.insert(SI); in collectUsersRecursive()
333 if (!collectUsersRecursive(*SI)) in collectUsersRecursive()
401 } else if (auto *SI = dyn_cast<SelectInst>(I)) { in replace() local
403 SI->getCondition(), getReplacement(SI->getTrueValue()), in replace()
404 getReplacement(SI->getFalseValue()), SI->getName(), nullptr, SI); in replace()
405 IC.InsertNewInstWith(NewSI, SI->getIterator()); in replace()
406 NewSI->takeName(SI); in replace()
407 WorkMap[SI] = NewSI; in replace()
579 static StoreInst *combineStoreToNewValue(InstCombinerImpl &IC, StoreInst &SI, in combineStoreToNewValue() argument
581 assert((!SI.isAtomic() || isSupportedAtomicType(V->getType())) && in combineStoreToNewValue()
584 Value *Ptr = SI.getPointerOperand(); in combineStoreToNewValue()
586 SI.getAllMetadata(MD); in combineStoreToNewValue()
589 IC.Builder.CreateAlignedStore(V, Ptr, SI.getAlign(), SI.isVolatile()); in combineStoreToNewValue()
590 NewStore->setAtomic(SI.getOrdering(), SI.getSyncScopeID()); in combineStoreToNewValue()
821 if (SelectInst *SI = dyn_cast<SelectInst>(P)) { in isObjectSizeLessThanOrEq() local
822 Worklist.push_back(SI->getTrueValue()); in isObjectSizeLessThanOrEq()
823 Worklist.push_back(SI->getFalseValue()); in isObjectSizeLessThanOrEq()
982 static bool canSimplifyNullStoreOrGEP(StoreInst &SI) { in canSimplifyNullStoreOrGEP() argument
983 if (NullPointerIsDefined(SI.getFunction(), SI.getPointerAddressSpace())) in canSimplifyNullStoreOrGEP()
986 auto *Ptr = SI.getPointerOperand(); in canSimplifyNullStoreOrGEP()
990 !NullPointerIsDefined(SI.getFunction(), SI.getPointerAddressSpace())); in canSimplifyNullStoreOrGEP()
1068 if (SelectInst *SI = dyn_cast<SelectInst>(Op)) { in visitLoadInst() local
1071 if (isSafeToLoadUnconditionally(SI->getOperand(1), LI.getType(), in visitLoadInst()
1072 Alignment, DL, SI) && in visitLoadInst()
1073 isSafeToLoadUnconditionally(SI->getOperand(2), LI.getType(), in visitLoadInst()
1074 Alignment, DL, SI)) { in visitLoadInst()
1076 Builder.CreateLoad(LI.getType(), SI->getOperand(1), in visitLoadInst()
1077 SI->getOperand(1)->getName() + ".val"); in visitLoadInst()
1079 Builder.CreateLoad(LI.getType(), SI->getOperand(2), in visitLoadInst()
1080 SI->getOperand(2)->getName() + ".val"); in visitLoadInst()
1086 return SelectInst::Create(SI->getCondition(), V1, V2); in visitLoadInst()
1090 if (isa<ConstantPointerNull>(SI->getOperand(1)) && in visitLoadInst()
1091 !NullPointerIsDefined(SI->getFunction(), in visitLoadInst()
1093 return replaceOperand(LI, 0, SI->getOperand(2)); in visitLoadInst()
1096 if (isa<ConstantPointerNull>(SI->getOperand(2)) && in visitLoadInst()
1097 !NullPointerIsDefined(SI->getFunction(), in visitLoadInst()
1099 return replaceOperand(LI, 0, SI->getOperand(1)); in visitLoadInst()
1180 static bool combineStoreToValueType(InstCombinerImpl &IC, StoreInst &SI) { in combineStoreToValueType() argument
1183 if (!SI.isUnordered()) in combineStoreToValueType()
1187 if (SI.getPointerOperand()->isSwiftError()) in combineStoreToValueType()
1190 Value *V = SI.getValueOperand(); in combineStoreToValueType()
1201 if (!SI.isAtomic() || isSupportedAtomicType(V->getType())) { in combineStoreToValueType()
1202 combineStoreToNewValue(IC, SI, V); in combineStoreToValueType()
1208 if (!SI.isAtomic() || isSupportedAtomicType(U->getType())) { in combineStoreToValueType()
1209 combineStoreToNewValue(IC, SI, U); in combineStoreToValueType()
1218 static bool unpackStoreToAggregate(InstCombinerImpl &IC, StoreInst &SI) { in unpackStoreToAggregate() argument
1221 if (!SI.isSimple()) in unpackStoreToAggregate()
1224 Value *V = SI.getValueOperand(); in unpackStoreToAggregate()
1235 combineStoreToNewValue(IC, SI, V); in unpackStoreToAggregate()
1251 const auto Align = SI.getAlign(); in unpackStoreToAggregate()
1255 auto *Addr = SI.getPointerOperand(); in unpackStoreToAggregate()
1271 NS->setAAMetadata(SI.getAAMetadata()); in unpackStoreToAggregate()
1282 combineStoreToNewValue(IC, SI, V); in unpackStoreToAggregate()
1295 const auto Align = SI.getAlign(); in unpackStoreToAggregate()
1299 auto *Addr = SI.getPointerOperand(); in unpackStoreToAggregate()
1317 NS->setAAMetadata(SI.getAAMetadata()); in unpackStoreToAggregate()
1356 Instruction *InstCombinerImpl::visitStoreInst(StoreInst &SI) { in visitStoreInst() argument
1357 Value *Val = SI.getOperand(0); in visitStoreInst()
1358 Value *Ptr = SI.getOperand(1); in visitStoreInst()
1361 if (combineStoreToValueType(*this, SI)) in visitStoreInst()
1362 return eraseInstFromFunction(SI); in visitStoreInst()
1367 Ptr, DL.getPrefTypeAlign(Val->getType()), DL, &SI, &AC, &DT); in visitStoreInst()
1368 if (KnownAlign > SI.getAlign()) in visitStoreInst()
1369 SI.setAlignment(KnownAlign); in visitStoreInst()
1373 if (unpackStoreToAggregate(*this, SI)) in visitStoreInst()
1374 return eraseInstFromFunction(SI); in visitStoreInst()
1377 if (Instruction *NewGEPI = replaceGEPIdxWithZero(*this, Ptr, SI)) in visitStoreInst()
1378 return replaceOperand(SI, 1, NewGEPI); in visitStoreInst()
1382 if (!SI.isUnordered()) return nullptr; in visitStoreInst()
1388 return eraseInstFromFunction(SI); in visitStoreInst()
1392 return eraseInstFromFunction(SI); in visitStoreInst()
1401 return eraseInstFromFunction(SI); in visitStoreInst()
1406 BasicBlock::iterator BBI(SI); in visitStoreInst()
1407 for (unsigned ScanInsts = 6; BBI != SI.getParent()->begin() && ScanInsts; in visitStoreInst()
1420 equivalentAddressValues(PrevSI->getOperand(1), SI.getOperand(1)) && in visitStoreInst()
1422 SI.getValueOperand()->getType()) { in visitStoreInst()
1427 Worklist.push(&SI); in visitStoreInst()
1439 assert(SI.isUnordered() && "can't eliminate ordering operation"); in visitStoreInst()
1440 return eraseInstFromFunction(SI); in visitStoreInst()
1455 if (canSimplifyNullStoreOrGEP(SI)) { in visitStoreInst()
1457 return replaceOperand(SI, 0, PoisonValue::get(Val->getType())); in visitStoreInst()
1464 if (removeInstructionsBeforeUnreachable(SI)) in visitStoreInst()
1465 return &SI; in visitStoreInst()
1470 handleUnreachableFrom(SI.getNextNode(), Worklist); in visitStoreInst()
1479 return eraseInstFromFunction(SI); in visitStoreInst()
1489 bool InstCombinerImpl::mergeStoreIntoSuccessor(StoreInst &SI) { in mergeStoreIntoSuccessor() argument
1490 if (!SI.isUnordered()) in mergeStoreIntoSuccessor()
1494 BasicBlock *StoreBB = SI.getParent(); in mergeStoreIntoSuccessor()
1518 OtherStore->getPointerOperand() != SI.getPointerOperand()) in mergeStoreIntoSuccessor()
1521 auto *SIVTy = SI.getValueOperand()->getType(); in mergeStoreIntoSuccessor()
1524 SI.hasSameSpecialState(OtherStore); in mergeStoreIntoSuccessor()
1568 for (BasicBlock::iterator I = StoreBB->begin(); &*I != &SI; ++I) { in mergeStoreIntoSuccessor()
1578 DebugLoc MergedLoc = DILocation::getMergedLocation(SI.getDebugLoc(), in mergeStoreIntoSuccessor()
1580 if (MergedVal != SI.getValueOperand()) { in mergeStoreIntoSuccessor()
1582 PHINode::Create(SI.getValueOperand()->getType(), 2, "storemerge"); in mergeStoreIntoSuccessor()
1583 PN->addIncoming(SI.getValueOperand(), SI.getParent()); in mergeStoreIntoSuccessor()
1594 new StoreInst(MergedVal, SI.getOperand(1), SI.isVolatile(), SI.getAlign(), in mergeStoreIntoSuccessor()
1595 SI.getOrdering(), SI.getSyncScopeID()); in mergeStoreIntoSuccessor()
1598 NewSI->mergeDIAssignID({&SI, OtherStore}); in mergeStoreIntoSuccessor()
1601 AAMDNodes AATags = SI.getAAMetadata(); in mergeStoreIntoSuccessor()
1606 eraseInstFromFunction(SI); in mergeStoreIntoSuccessor()