Fix mis-optimized identical submodule subtract, bug581. Take 2.
This commit is contained in:
parent
30f6c0e105
commit
c7a088faa5
|
|
@ -1135,10 +1135,17 @@ struct AstVarRef : public AstNodeVarRef {
|
||||||
ASTNODE_NODE_FUNCS(VarRef, VARREF)
|
ASTNODE_NODE_FUNCS(VarRef, VARREF)
|
||||||
virtual void dump(ostream& str);
|
virtual void dump(ostream& str);
|
||||||
virtual V3Hash sameHash() const { return V3Hash(V3Hash(varp()->name()),V3Hash(hiername())); }
|
virtual V3Hash sameHash() const { return V3Hash(V3Hash(varp()->name()),V3Hash(hiername())); }
|
||||||
virtual bool same(AstNode* samep) const {
|
virtual bool same(AstNode* samep) const { return same(samep->castVarRef()); }
|
||||||
if (varScopep()) return varScopep()==samep->castVarRef()->varScopep();
|
inline bool same(AstVarRef* samep) const {
|
||||||
else return (hiername()==samep->castVarRef()->hiername()
|
if (varScopep()) return (varScopep()==samep->varScopep()
|
||||||
&& varp()->name()==samep->castVarRef()->varp()->name()); }
|
&& lvalue()==samep->lvalue());
|
||||||
|
else return (hiername()==samep->hiername()
|
||||||
|
&& varp()->name()==samep->varp()->name()
|
||||||
|
&& lvalue()==samep->lvalue()); }
|
||||||
|
inline bool sameNoLvalue(AstVarRef* samep) const {
|
||||||
|
if (varScopep()) return (varScopep()==samep->varScopep());
|
||||||
|
else return (hiername()==samep->hiername()
|
||||||
|
&& varp()->name()==samep->varp()->name()); }
|
||||||
virtual int instrCount() const { return widthInstrs()*(lvalue()?1:instrCountLd()); }
|
virtual int instrCount() const { return widthInstrs()*(lvalue()?1:instrCountLd()); }
|
||||||
virtual string emitVerilog() { V3ERROR_NA; return ""; } // Implemented specially
|
virtual string emitVerilog() { V3ERROR_NA; return ""; } // Implemented specially
|
||||||
virtual string emitC() { V3ERROR_NA; return ""; }
|
virtual string emitC() { V3ERROR_NA; return ""; }
|
||||||
|
|
|
||||||
|
|
@ -415,9 +415,7 @@ private:
|
||||||
// Avoid comparing widthMin's, which results in lost optimization attempts
|
// Avoid comparing widthMin's, which results in lost optimization attempts
|
||||||
// If cleanup sameTree to be smarter, this can be restored.
|
// If cleanup sameTree to be smarter, this can be restored.
|
||||||
//return node1p->sameTree(node2p);
|
//return node1p->sameTree(node2p);
|
||||||
return node1p->castVarRef()->varp() == node2p->castVarRef()->varp()
|
return node1p->same(node2p);
|
||||||
&& node1p->castVarRef()->varScopep() == node2p->castVarRef()->varScopep()
|
|
||||||
&& node1p->castVarRef()->lvalue() == node2p->castVarRef()->lvalue();
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -432,7 +430,7 @@ private:
|
||||||
AstVarRef* elsevarp = elsep->lhsp()->castVarRef();
|
AstVarRef* elsevarp = elsep->lhsp()->castVarRef();
|
||||||
if (!ifvarp || !elsevarp) return false;
|
if (!ifvarp || !elsevarp) return false;
|
||||||
if (ifvarp->isWide()) return false; // Would need temporaries, so not worth it
|
if (ifvarp->isWide()) return false; // Would need temporaries, so not worth it
|
||||||
if (ifvarp->varp() != elsevarp->varp()) return false;
|
if (!ifvarp->sameTree(elsevarp)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool operandIfIf(AstNodeIf* nodep) {
|
bool operandIfIf(AstNodeIf* nodep) {
|
||||||
|
|
@ -777,7 +775,7 @@ private:
|
||||||
AstSel* sel2p = nextp->lhsp()->castSel(); if (!sel2p) return false;
|
AstSel* sel2p = nextp->lhsp()->castSel(); if (!sel2p) return false;
|
||||||
AstVarRef* varref1p = sel1p->fromp()->castVarRef(); if (!varref1p) return false;
|
AstVarRef* varref1p = sel1p->fromp()->castVarRef(); if (!varref1p) return false;
|
||||||
AstVarRef* varref2p = sel2p->fromp()->castVarRef(); if (!varref2p) return false;
|
AstVarRef* varref2p = sel2p->fromp()->castVarRef(); if (!varref2p) return false;
|
||||||
if (varref1p->varp() != varref2p->varp()) return false;
|
if (!varref1p->sameTree(varref2p)) return false;
|
||||||
AstConst* con1p = sel1p->lsbp()->castConst(); if (!con1p) return false;
|
AstConst* con1p = sel1p->lsbp()->castConst(); if (!con1p) return false;
|
||||||
AstConst* con2p = sel2p->lsbp()->castConst(); if (!con2p) return false;
|
AstConst* con2p = sel2p->lsbp()->castConst(); if (!con2p) return false;
|
||||||
// We need to make sure there's no self-references involved in either
|
// We need to make sure there's no self-references involved in either
|
||||||
|
|
@ -828,7 +826,7 @@ private:
|
||||||
bool replaceNodeAssign(AstNodeAssign* nodep) {
|
bool replaceNodeAssign(AstNodeAssign* nodep) {
|
||||||
if (nodep->lhsp()->castVarRef()
|
if (nodep->lhsp()->castVarRef()
|
||||||
&& nodep->rhsp()->castVarRef()
|
&& nodep->rhsp()->castVarRef()
|
||||||
&& nodep->lhsp()->sameTree(nodep->rhsp())
|
&& nodep->lhsp()->castVarRef()->sameNoLvalue(nodep->rhsp()->castVarRef())
|
||||||
&& !nodep->castAssignDly()) {
|
&& !nodep->castAssignDly()) {
|
||||||
// X = X. Quite pointless, though X <= X may override another earlier assignment
|
// X = X. Quite pointless, though X <= X may override another earlier assignment
|
||||||
if (nodep->castAssignW()) {
|
if (nodep->castAssignW()) {
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ module t (/*AUTOARG*/
|
||||||
$write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum);
|
$write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum);
|
||||||
if (crc !== 64'hc77bb9b3784ea091) $stop;
|
if (crc !== 64'hc77bb9b3784ea091) $stop;
|
||||||
// What checksum will we end up with (above print should match)
|
// What checksum will we end up with (above print should match)
|
||||||
`define EXPECTED_SUM 64'hf15989544a22e48a
|
`define EXPECTED_SUM 64'h8a78c2ec4946ac38
|
||||||
if (sum !== `EXPECTED_SUM) $stop;
|
if (sum !== `EXPECTED_SUM) $stop;
|
||||||
$write("*-* All Finished *-*\n");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
|
|
@ -218,8 +218,6 @@ module clz(
|
||||||
reg [2:0] clz_byte2;
|
reg [2:0] clz_byte2;
|
||||||
reg [2:0] clz_byte3;
|
reg [2:0] clz_byte3;
|
||||||
|
|
||||||
assign out = data_i[6:0];
|
|
||||||
|
|
||||||
always @*
|
always @*
|
||||||
case (data_i)
|
case (data_i)
|
||||||
`def_1xxx_xxxx : clz_byte0 = 3'b000;
|
`def_1xxx_xxxx : clz_byte0 = 3'b000;
|
||||||
|
|
@ -275,6 +273,7 @@ module clz(
|
||||||
default : clz_byte3 = 3'bxxx;
|
default : clz_byte3 = 3'bxxx;
|
||||||
endcase
|
endcase
|
||||||
|
|
||||||
|
assign out = {4'b0000, clz_byte1};
|
||||||
|
|
||||||
endmodule // clz
|
endmodule // clz
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue