/// is either a select instruction or a phi node). \p I is the instruction
/// being processed, and it is assumed equivalent to "Cond ? TrueVal :
/// FalseVal".
- const SCEV *createNodeForSelectOrPHIInstWithICmpInstCond(Instruction *I,
- ICmpInst *Cond,
- Value *TrueVal,
- Value *FalseVal);
+ std::optional<const SCEV *>
+ createNodeForSelectOrPHIInstWithICmpInstCond(Instruction *I, ICmpInst *Cond,
+ Value *TrueVal, Value *FalseVal);
/// See if we can model this select-like instruction via umin_seq expression.
const SCEV *createNodeForSelectOrPHIViaUMinSeq(Value *I, Value *Cond,
return FC.Found;
}
-const SCEV *ScalarEvolution::createNodeForSelectOrPHIInstWithICmpInstCond(
- Instruction *I, ICmpInst *Cond, Value *TrueVal, Value *FalseVal) {
+std::optional<const SCEV *>
+ScalarEvolution::createNodeForSelectOrPHIInstWithICmpInstCond(Instruction *I,
+ ICmpInst *Cond,
+ Value *TrueVal,
+ Value *FalseVal) {
// Try to match some simple smax or umax patterns.
auto *ICI = Cond;
break;
}
- return getUnknown(I);
+ return std::nullopt;
}
static std::optional<const SCEV *>
if (auto *I = dyn_cast<Instruction>(V)) {
if (auto *ICI = dyn_cast<ICmpInst>(Cond)) {
- const SCEV *S = createNodeForSelectOrPHIInstWithICmpInstCond(
- I, ICI, TrueVal, FalseVal);
- if (!isa<SCEVUnknown>(S))
- return S;
+ if (std::optional<const SCEV *> S =
+ createNodeForSelectOrPHIInstWithICmpInstCond(I, ICI, TrueVal,
+ FalseVal))
+ return *S;
}
}