mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 18:13:50 +02:00
Fix tautological-compare warnings.
This commit is contained in:
+11
-5
@@ -1441,16 +1441,22 @@ class ConstVisitor final : public VNVisitor {
|
||||
|
||||
static bool operandsSame(AstNode* node1p, AstNode* node2p) {
|
||||
// For now we just detect constants & simple vars, though it could be more generic
|
||||
if (VN_IS(node1p, Const) && VN_IS(node2p, Const)) {
|
||||
return node1p->sameGateTree(node2p);
|
||||
} else if (VN_IS(node1p, VarRef) && VN_IS(node2p, VarRef)) {
|
||||
if (VN_IS(node1p, Const) && VN_IS(node2p, Const)) return node1p->sameGateTree(node2p);
|
||||
if (VN_IS(node1p, VarRef) && VN_IS(node2p, VarRef)) {
|
||||
// Avoid comparing widthMin's, which results in lost optimization attempts
|
||||
// If cleanup sameGateTree to be smarter, this can be restored.
|
||||
// return node1p->sameGateTree(node2p);
|
||||
return node1p->isSame(node2p);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// Pattern created by coverage-line; avoid compiler tautological-compare warning
|
||||
if (AstAnd* const and1p = VN_CAST(node1p, And)) {
|
||||
if (AstAnd* const and2p = VN_CAST(node2p, And)) {
|
||||
if (VN_IS(and1p->lhsp(), Const) && VN_IS(and1p->rhsp(), NodeVarRef)
|
||||
&& VN_IS(and2p->lhsp(), Const) && VN_IS(and2p->rhsp(), NodeVarRef))
|
||||
return node1p->sameGateTree(node2p);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool ifSameAssign(const AstNodeIf* nodep) {
|
||||
const AstNodeAssign* const thensp = VN_CAST(nodep->thensp(), NodeAssign);
|
||||
|
||||
Reference in New Issue
Block a user