[Moore][NFC] Fix warning when building Moore components (#7566)

The corresponding code snippet has a problem for checking whether the
pointer pointing to a module op is a nullptr. This commit rewrites its
code to fix the warning.
This commit is contained in:
cepheus 2024-09-04 11:17:15 +08:00 committed by GitHub
parent c0a77be1f4
commit b441059067
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 11 deletions

View File

@ -518,17 +518,17 @@ LogicalResult AssignedVariableOp::canonicalize(AssignedVariableOp op,
// Eliminate variables that feed an output port of the same name.
for (auto &use : op->getUses()) {
auto outputOp = dyn_cast<OutputOp>(use.getOwner());
if (!outputOp)
continue;
auto moduleOp = dyn_cast<SVModuleOp>(outputOp.getParentOp());
if (!moduleOp)
break;
auto moduleType = moduleOp.getModuleType();
auto portName = moduleType.getOutputNameAttr(use.getOperandNumber());
if (portName == op.getNameAttr()) {
rewriter.replaceOp(op, op.getInput());
return success();
auto *useOwner = use.getOwner();
if (auto outputOp = dyn_cast<OutputOp>(useOwner)) {
if (auto moduleOp = dyn_cast<SVModuleOp>(outputOp->getParentOp())) {
auto moduleType = moduleOp.getModuleType();
auto portName = moduleType.getOutputNameAttr(use.getOperandNumber());
if (portName == op.getNameAttr()) {
rewriter.replaceOp(op, op.getInput());
return success();
}
} else
break;
}
}