Lines Matching defs:SI

308     } else if (auto *SI = dyn_cast<SelectInst>(Inst)) {
309 if (!isa<Instruction>(SI->getTrueValue()) ||
310 !isa<Instruction>(SI->getFalseValue()))
313 if (!isAvailable(cast<Instruction>(SI->getTrueValue())) ||
314 !isAvailable(cast<Instruction>(SI->getFalseValue()))) {
318 Worklist.insert(SI);
319 if (!collectUsersRecursive(*SI))
382 } else if (auto *SI = dyn_cast<SelectInst>(I)) {
383 Value *TrueValue = SI->getTrueValue();
384 Value *FalseValue = SI->getFalseValue();
389 auto *NewSI = SelectInst::Create(SI->getCondition(), TrueValue, FalseValue,
390 SI->getName(), nullptr, SI);
391 IC.InsertNewInstWith(NewSI, SI->getIterator());
392 NewSI->takeName(SI);
393 WorkMap[SI] = NewSI;
564 static StoreInst *combineStoreToNewValue(InstCombinerImpl &IC, StoreInst &SI,
566 assert((!SI.isAtomic() || isSupportedAtomicType(V->getType())) &&
569 Value *Ptr = SI.getPointerOperand();
571 SI.getAllMetadata(MD);
574 IC.Builder.CreateAlignedStore(V, Ptr, SI.getAlign(), SI.isVolatile());
575 NewStore->setAtomic(SI.getOrdering(), SI.getSyncScopeID());
799 if (SelectInst *SI = dyn_cast<SelectInst>(P)) {
800 Worklist.push_back(SI->getTrueValue());
801 Worklist.push_back(SI->getFalseValue());
960 static bool canSimplifyNullStoreOrGEP(StoreInst &SI) {
961 if (NullPointerIsDefined(SI.getFunction(), SI.getPointerAddressSpace()))
964 auto *Ptr = SI.getPointerOperand();
968 !NullPointerIsDefined(SI.getFunction(), SI.getPointerAddressSpace()));
1038 if (SelectInst *SI = dyn_cast<SelectInst>(Op)) {
1041 if (isSafeToLoadUnconditionally(SI->getOperand(1), LI.getType(),
1042 Alignment, DL, SI) &&
1043 isSafeToLoadUnconditionally(SI->getOperand(2), LI.getType(),
1044 Alignment, DL, SI)) {
1046 Builder.CreateLoad(LI.getType(), SI->getOperand(1),
1047 SI->getOperand(1)->getName() + ".val");
1049 Builder.CreateLoad(LI.getType(), SI->getOperand(2),
1050 SI->getOperand(2)->getName() + ".val");
1060 return SelectInst::Create(SI->getCondition(), V1, V2);
1064 if (isa<ConstantPointerNull>(SI->getOperand(1)) &&
1065 !NullPointerIsDefined(SI->getFunction(),
1067 return replaceOperand(LI, 0, SI->getOperand(2));
1070 if (isa<ConstantPointerNull>(SI->getOperand(2)) &&
1071 !NullPointerIsDefined(SI->getFunction(),
1073 return replaceOperand(LI, 0, SI->getOperand(1));
1154 static bool combineStoreToValueType(InstCombinerImpl &IC, StoreInst &SI) {
1157 if (!SI.isUnordered())
1161 if (SI.getPointerOperand()->isSwiftError())
1164 Value *V = SI.getValueOperand();
1175 if (!SI.isAtomic() || isSupportedAtomicType(V->getType())) {
1176 combineStoreToNewValue(IC, SI, V);
1182 if (!SI.isAtomic() || isSupportedAtomicType(U->getType())) {
1183 combineStoreToNewValue(IC, SI, U);
1192 static bool unpackStoreToAggregate(InstCombinerImpl &IC, StoreInst &SI) {
1195 if (!SI.isSimple())
1198 Value *V = SI.getValueOperand();
1209 combineStoreToNewValue(IC, SI, V);
1221 const auto Align = SI.getAlign();
1225 auto *Addr = SI.getPointerOperand();
1238 NS->setAAMetadata(SI.getAAMetadata());
1249 combineStoreToNewValue(IC, SI, V);
1262 const auto Align = SI.getAlign();
1266 auto *Addr = SI.getPointerOperand();
1284 NS->setAAMetadata(SI.getAAMetadata());
1323 Instruction *InstCombinerImpl::visitStoreInst(StoreInst &SI) {
1324 Value *Val = SI.getOperand(0);
1325 Value *Ptr = SI.getOperand(1);
1328 if (combineStoreToValueType(*this, SI))
1329 return eraseInstFromFunction(SI);
1332 if (unpackStoreToAggregate(*this, SI))
1333 return eraseInstFromFunction(SI);
1336 if (Instruction *NewGEPI = replaceGEPIdxWithZero(*this, Ptr, SI))
1337 return replaceOperand(SI, 1, NewGEPI);
1341 if (!SI.isUnordered()) return nullptr;
1347 return eraseInstFromFunction(SI);
1351 return eraseInstFromFunction(SI);
1360 return eraseInstFromFunction(SI);
1365 BasicBlock::iterator BBI(SI);
1366 for (unsigned ScanInsts = 6; BBI != SI.getParent()->begin() && ScanInsts;
1379 equivalentAddressValues(PrevSI->getOperand(1), SI.getOperand(1)) &&
1381 SI.getValueOperand()->getType()) {
1386 Worklist.push(&SI);
1398 assert(SI.isUnordered() && "can't eliminate ordering operation");
1399 return eraseInstFromFunction(SI);
1414 if (canSimplifyNullStoreOrGEP(SI)) {
1416 return replaceOperand(SI, 0, PoisonValue::get(Val->getType()));
1423 if (removeInstructionsBeforeUnreachable(SI))
1424 return &SI;
1429 handleUnreachableFrom(SI.getNextNode(), Worklist);
1438 return eraseInstFromFunction(SI);
1448 bool InstCombinerImpl::mergeStoreIntoSuccessor(StoreInst &SI) {
1449 if (!SI.isUnordered())
1453 BasicBlock *StoreBB = SI.getParent();
1465 // for example, if SI is in an infinite loop.
1477 OtherStore->getPointerOperand() != SI.getPointerOperand())
1480 auto *SIVTy = SI.getValueOperand()->getType();
1483 SI.hasSameSpecialState(OtherStore);
1510 // if/then triangle. See if there is a store to the same ptr as SI that
1527 for (BasicBlock::iterator I = StoreBB->begin(); &*I != &SI; ++I) {
1537 DebugLoc MergedLoc = DILocation::getMergedLocation(SI.getDebugLoc(),
1539 if (MergedVal != SI.getValueOperand()) {
1541 PHINode::Create(SI.getValueOperand()->getType(), 2, "storemerge");
1542 PN->addIncoming(SI.getValueOperand(), SI.getParent());
1553 new StoreInst(MergedVal, SI.getOperand(1), SI.isVolatile(), SI.getAlign(),
1554 SI.getOrdering(), SI.getSyncScopeID());
1557 NewSI->mergeDIAssignID({&SI, OtherStore});
1560 AAMDNodes AATags = SI.getAAMetadata();
1565 eraseInstFromFunction(SI);