Lines Matching defs:SI
322 } else if (auto *SI = dyn_cast<SelectInst>(Inst)) {
323 if (!isa<Instruction>(SI->getTrueValue()) ||
324 !isa<Instruction>(SI->getFalseValue()))
327 if (!isAvailable(cast<Instruction>(SI->getTrueValue())) ||
328 !isAvailable(cast<Instruction>(SI->getFalseValue()))) {
332 Worklist.insert(SI);
333 if (!collectUsersRecursive(*SI))
396 } else if (auto *SI = dyn_cast<SelectInst>(I)) {
397 Value *TrueValue = SI->getTrueValue();
398 Value *FalseValue = SI->getFalseValue();
403 auto *NewSI = SelectInst::Create(SI->getCondition(), TrueValue, FalseValue,
404 SI->getName(), nullptr, SI);
405 IC.InsertNewInstWith(NewSI, SI->getIterator());
406 NewSI->takeName(SI);
407 WorkMap[SI] = NewSI;
578 static StoreInst *combineStoreToNewValue(InstCombinerImpl &IC, StoreInst &SI,
580 assert((!SI.isAtomic() || isSupportedAtomicType(V->getType())) &&
583 Value *Ptr = SI.getPointerOperand();
585 SI.getAllMetadata(MD);
588 IC.Builder.CreateAlignedStore(V, Ptr, SI.getAlign(), SI.isVolatile());
589 NewStore->setAtomic(SI.getOrdering(), SI.getSyncScopeID());
820 if (SelectInst *SI = dyn_cast<SelectInst>(P)) {
821 Worklist.push_back(SI->getTrueValue());
822 Worklist.push_back(SI->getFalseValue());
981 static bool canSimplifyNullStoreOrGEP(StoreInst &SI) {
982 if (NullPointerIsDefined(SI.getFunction(), SI.getPointerAddressSpace()))
985 auto *Ptr = SI.getPointerOperand();
989 !NullPointerIsDefined(SI.getFunction(), SI.getPointerAddressSpace()));
1067 if (SelectInst *SI = dyn_cast<SelectInst>(Op)) {
1070 if (isSafeToLoadUnconditionally(SI->getOperand(1), LI.getType(),
1071 Alignment, DL, SI) &&
1072 isSafeToLoadUnconditionally(SI->getOperand(2), LI.getType(),
1073 Alignment, DL, SI)) {
1075 Builder.CreateLoad(LI.getType(), SI->getOperand(1),
1076 SI->getOperand(1)->getName() + ".val");
1078 Builder.CreateLoad(LI.getType(), SI->getOperand(2),
1079 SI->getOperand(2)->getName() + ".val");
1085 return SelectInst::Create(SI->getCondition(), V1, V2);
1089 if (isa<ConstantPointerNull>(SI->getOperand(1)) &&
1090 !NullPointerIsDefined(SI->getFunction(),
1092 return replaceOperand(LI, 0, SI->getOperand(2));
1095 if (isa<ConstantPointerNull>(SI->getOperand(2)) &&
1096 !NullPointerIsDefined(SI->getFunction(),
1098 return replaceOperand(LI, 0, SI->getOperand(1));
1179 static bool combineStoreToValueType(InstCombinerImpl &IC, StoreInst &SI) {
1182 if (!SI.isUnordered())
1186 if (SI.getPointerOperand()->isSwiftError())
1189 Value *V = SI.getValueOperand();
1200 if (!SI.isAtomic() || isSupportedAtomicType(V->getType())) {
1201 combineStoreToNewValue(IC, SI, V);
1207 if (!SI.isAtomic() || isSupportedAtomicType(U->getType())) {
1208 combineStoreToNewValue(IC, SI, U);
1217 static bool unpackStoreToAggregate(InstCombinerImpl &IC, StoreInst &SI) {
1220 if (!SI.isSimple())
1223 Value *V = SI.getValueOperand();
1234 combineStoreToNewValue(IC, SI, V);
1250 const auto Align = SI.getAlign();
1254 auto *Addr = SI.getPointerOperand();
1270 NS->setAAMetadata(SI.getAAMetadata());
1281 combineStoreToNewValue(IC, SI, V);
1294 const auto Align = SI.getAlign();
1298 auto *Addr = SI.getPointerOperand();
1316 NS->setAAMetadata(SI.getAAMetadata());
1355 Instruction *InstCombinerImpl::visitStoreInst(StoreInst &SI) {
1356 Value *Val = SI.getOperand(0);
1357 Value *Ptr = SI.getOperand(1);
1360 if (combineStoreToValueType(*this, SI))
1361 return eraseInstFromFunction(SI);
1366 Ptr, DL.getPrefTypeAlign(Val->getType()), DL, &SI, &AC, &DT);
1367 if (KnownAlign > SI.getAlign())
1368 SI.setAlignment(KnownAlign);
1372 if (unpackStoreToAggregate(*this, SI))
1373 return eraseInstFromFunction(SI);
1376 if (Instruction *NewGEPI = replaceGEPIdxWithZero(*this, Ptr, SI))
1377 return replaceOperand(SI, 1, NewGEPI);
1381 if (!SI.isUnordered()) return nullptr;
1387 return eraseInstFromFunction(SI);
1391 return eraseInstFromFunction(SI);
1400 return eraseInstFromFunction(SI);
1405 BasicBlock::iterator BBI(SI);
1406 for (unsigned ScanInsts = 6; BBI != SI.getParent()->begin() && ScanInsts;
1419 equivalentAddressValues(PrevSI->getOperand(1), SI.getOperand(1)) &&
1421 SI.getValueOperand()->getType()) {
1426 Worklist.push(&SI);
1438 assert(SI.isUnordered() && "can't eliminate ordering operation");
1439 return eraseInstFromFunction(SI);
1454 if (canSimplifyNullStoreOrGEP(SI)) {
1456 return replaceOperand(SI, 0, PoisonValue::get(Val->getType()));
1463 if (removeInstructionsBeforeUnreachable(SI))
1464 return &SI;
1469 handleUnreachableFrom(SI.getNextNode(), Worklist);
1478 return eraseInstFromFunction(SI);
1488 bool InstCombinerImpl::mergeStoreIntoSuccessor(StoreInst &SI) {
1489 if (!SI.isUnordered())
1493 BasicBlock *StoreBB = SI.getParent();
1505 // for example, if SI is in an infinite loop.
1517 OtherStore->getPointerOperand() != SI.getPointerOperand())
1520 auto *SIVTy = SI.getValueOperand()->getType();
1523 SI.hasSameSpecialState(OtherStore);
1550 // if/then triangle. See if there is a store to the same ptr as SI that
1567 for (BasicBlock::iterator I = StoreBB->begin(); &*I != &SI; ++I) {
1577 DebugLoc MergedLoc = DILocation::getMergedLocation(SI.getDebugLoc(),
1579 if (MergedVal != SI.getValueOperand()) {
1581 PHINode::Create(SI.getValueOperand()->getType(), 2, "storemerge");
1582 PN->addIncoming(SI.getValueOperand(), SI.getParent());
1593 new StoreInst(MergedVal, SI.getOperand(1), SI.isVolatile(), SI.getAlign(),
1594 SI.getOrdering(), SI.getSyncScopeID());
1597 NewSI->mergeDIAssignID({&SI, OtherStore});
1600 AAMDNodes AATags = SI.getAAMetadata();
1605 eraseInstFromFunction(SI);