@@ -1366,68 +1366,6 @@ Value *SCEVExpander::expandCodeFor(const SCEV *SH, Type *Ty) {
1366
1366
return V;
1367
1367
}
1368
1368
1369
- static bool
1370
- canReuseInstruction (ScalarEvolution &SE, const SCEV *S, Instruction *I,
1371
- SmallVectorImpl<Instruction *> &DropPoisonGeneratingInsts) {
1372
- // If the instruction cannot be poison, it's always safe to reuse.
1373
- if (programUndefinedIfPoison (I))
1374
- return true ;
1375
-
1376
- // Otherwise, it is possible that I is more poisonous that S. Collect the
1377
- // poison-contributors of S, and then check whether I has any additional
1378
- // poison-contributors. Poison that is contributed through poison-generating
1379
- // flags is handled by dropping those flags instead.
1380
- SmallPtrSet<const Value *, 8 > PoisonVals;
1381
- SE.getPoisonGeneratingValues (PoisonVals, S);
1382
-
1383
- SmallVector<Value *> Worklist;
1384
- SmallPtrSet<Value *, 8 > Visited;
1385
- Worklist.push_back (I);
1386
- while (!Worklist.empty ()) {
1387
- Value *V = Worklist.pop_back_val ();
1388
- if (!Visited.insert (V).second )
1389
- continue ;
1390
-
1391
- // Avoid walking large instruction graphs.
1392
- if (Visited.size () > 16 )
1393
- return false ;
1394
-
1395
- // Either the value can't be poison, or the S would also be poison if it
1396
- // is.
1397
- if (PoisonVals.contains (V) || isGuaranteedNotToBePoison (V))
1398
- continue ;
1399
-
1400
- auto *I = dyn_cast<Instruction>(V);
1401
- if (!I)
1402
- return false ;
1403
-
1404
- // Disjoint or instructions are interpreted as adds by SCEV. However, we
1405
- // can't replace an arbitrary add with disjoint or, even if we drop the
1406
- // flag. We would need to convert the or into an add.
1407
- if (auto *PDI = dyn_cast<PossiblyDisjointInst>(I))
1408
- if (PDI->isDisjoint ())
1409
- return false ;
1410
-
1411
- // FIXME: Ignore vscale, even though it technically could be poison. Do this
1412
- // because SCEV currently assumes it can't be poison. Remove this special
1413
- // case once we proper model when vscale can be poison.
1414
- if (auto *II = dyn_cast<IntrinsicInst>(I);
1415
- II && II->getIntrinsicID () == Intrinsic::vscale)
1416
- continue ;
1417
-
1418
- if (canCreatePoison (cast<Operator>(I), /* ConsiderFlagsAndMetadata*/ false ))
1419
- return false ;
1420
-
1421
- // If the instruction can't create poison, we can recurse to its operands.
1422
- if (I->hasPoisonGeneratingFlagsOrMetadata ())
1423
- DropPoisonGeneratingInsts.push_back (I);
1424
-
1425
- for (Value *Op : I->operands ())
1426
- Worklist.push_back (Op);
1427
- }
1428
- return true ;
1429
- }
1430
-
1431
1369
Value *SCEVExpander::FindValueInExprValueMap (
1432
1370
const SCEV *S, const Instruction *InsertPt,
1433
1371
SmallVectorImpl<Instruction *> &DropPoisonGeneratingInsts) {
@@ -1455,7 +1393,7 @@ Value *SCEVExpander::FindValueInExprValueMap(
1455
1393
continue ;
1456
1394
1457
1395
// Make sure reusing the instruction is poison-safe.
1458
- if (canReuseInstruction (SE, S, EntInst, DropPoisonGeneratingInsts))
1396
+ if (SE. canReuseInstruction (S, EntInst, DropPoisonGeneratingInsts))
1459
1397
return V;
1460
1398
DropPoisonGeneratingInsts.clear ();
1461
1399
}
0 commit comments