[SCCP] Make check for unknown/undef in unary op handling more explicit (NFCI)

Make the implementation more similar to other functions, by
explicitly skipping an unknown/undef first, and always falling
back to overdefined at the end. I don't think it makes a difference
now, but could make one once the constant evaluation can fail. In
that case we would directly mark the result as overdefined now,
rather than keeping it unknown (and later making it overdefined
because we think it's undef-based).
This commit is contained in:
Nikita Popov 2022-07-14 10:52:19 +02:00
parent 3e0bf1c7a9
commit ebc54e0cd4
1 changed files with 4 additions and 4 deletions

View File

@ -953,15 +953,15 @@ void SCCPInstVisitor::visitUnaryOperator(Instruction &I) {
if (isOverdefined(IV))
return (void)markOverdefined(&I);
// If something is unknown/undef, wait for it to resolve.
if (V0State.isUnknownOrUndef())
return;
if (isConstant(V0State))
if (Constant *C = ConstantFoldUnaryOpOperand(I.getOpcode(),
getConstant(V0State), DL))
return (void)markConstant(IV, &I, C);
// If something is undef, wait for it to resolve.
if (!isOverdefined(V0State))
return;
markOverdefined(&I);
}