@@ -1301,12 +1301,9 @@ static ValueLatticeElement constantFoldUser(User *Usr, Value *Op,
1301
1301
return ValueLatticeElement::getOverdefined ();
1302
1302
}
1303
1303
1304
- // / Compute the value of Val on the edge BBFrom -> BBTo. Returns false if
1305
- // / Val is not constrained on the edge. Result is unspecified if return value
1306
- // / is false.
1307
- static std::optional<ValueLatticeElement> getEdgeValueLocal (Value *Val,
1308
- BasicBlock *BBFrom,
1309
- BasicBlock *BBTo) {
1304
+ // / Compute the value of Val on the edge BBFrom -> BBTo.
1305
+ static ValueLatticeElement getEdgeValueLocal (Value *Val, BasicBlock *BBFrom,
1306
+ BasicBlock *BBTo) {
1310
1307
// TODO: Handle more complex conditionals. If (v == 0 || v2 < 1) is false, we
1311
1308
// know that v != 0.
1312
1309
if (BranchInst *BI = dyn_cast<BranchInst>(BBFrom->getTerminator ())) {
@@ -1380,15 +1377,15 @@ static std::optional<ValueLatticeElement> getEdgeValueLocal(Value *Val,
1380
1377
if (SwitchInst *SI = dyn_cast<SwitchInst>(BBFrom->getTerminator ())) {
1381
1378
Value *Condition = SI->getCondition ();
1382
1379
if (!isa<IntegerType>(Val->getType ()))
1383
- return std::nullopt ;
1380
+ return ValueLatticeElement::getOverdefined () ;
1384
1381
bool ValUsesConditionAndMayBeFoldable = false ;
1385
1382
if (Condition != Val) {
1386
1383
// Check if Val has Condition as an operand.
1387
1384
if (User *Usr = dyn_cast<User>(Val))
1388
1385
ValUsesConditionAndMayBeFoldable = isOperationFoldable (Usr) &&
1389
1386
usesOperand (Usr, Condition);
1390
1387
if (!ValUsesConditionAndMayBeFoldable)
1391
- return std::nullopt ;
1388
+ return ValueLatticeElement::getOverdefined () ;
1392
1389
}
1393
1390
assert ((Condition == Val || ValUsesConditionAndMayBeFoldable) &&
1394
1391
" Condition != Val nor Val doesn't use Condition" );
@@ -1406,7 +1403,7 @@ static std::optional<ValueLatticeElement> getEdgeValueLocal(Value *Val,
1406
1403
ValueLatticeElement EdgeLatticeVal =
1407
1404
constantFoldUser (Usr, Condition, CaseValue, DL);
1408
1405
if (EdgeLatticeVal.isOverdefined ())
1409
- return std::nullopt ;
1406
+ return ValueLatticeElement::getOverdefined () ;
1410
1407
EdgeVal = EdgeLatticeVal.getConstantRange ();
1411
1408
}
1412
1409
if (DefaultCase) {
@@ -1423,7 +1420,7 @@ static std::optional<ValueLatticeElement> getEdgeValueLocal(Value *Val,
1423
1420
}
1424
1421
return ValueLatticeElement::getRange (std::move (EdgesVals));
1425
1422
}
1426
- return std::nullopt ;
1423
+ return ValueLatticeElement::getOverdefined () ;
1427
1424
}
1428
1425
1429
1426
// / Compute the value of Val on the edge BBFrom -> BBTo or the value at
@@ -1435,9 +1432,7 @@ LazyValueInfoImpl::getEdgeValue(Value *Val, BasicBlock *BBFrom,
1435
1432
if (Constant *VC = dyn_cast<Constant>(Val))
1436
1433
return ValueLatticeElement::get (VC);
1437
1434
1438
- ValueLatticeElement LocalResult =
1439
- getEdgeValueLocal (Val, BBFrom, BBTo)
1440
- .value_or (ValueLatticeElement::getOverdefined ());
1435
+ ValueLatticeElement LocalResult = getEdgeValueLocal (Val, BBFrom, BBTo);
1441
1436
if (hasSingleValue (LocalResult))
1442
1437
// Can't get any more precise here
1443
1438
return LocalResult;
0 commit comments