aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorJack Koenig2017-07-06 18:16:33 -0700
committerJack2017-07-17 14:23:57 -0700
commit427095ad97ac31e994fee3d083eb18f78e701004 (patch)
tree50d8b5fdd8dfc297f0727ea203ad9e15548a7bef /src/main
parent661147d84d8c27a5b4f051ced12ebf7efecb40dc (diff)
Fix ConstProp bug where multiple names would swap with one
Fixes issue in https://github.com/freechipsproject/rocket-chip/pull/848
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/firrtl/transforms/ConstantPropagation.scala4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/transforms/ConstantPropagation.scala b/src/main/scala/firrtl/transforms/ConstantPropagation.scala
index bf8b1a55..46c12b2d 100644
--- a/src/main/scala/firrtl/transforms/ConstantPropagation.scala
+++ b/src/main/scala/firrtl/transforms/ConstantPropagation.scala
@@ -304,7 +304,9 @@ class ConstantPropagation extends Transform {
// When propagating a reference, check if we want to keep the name that would be deleted
def propagateRef(lname: String, value: Expression): Unit = {
value match {
- case WRef(rname,_,_,_) if betterName(lname, rname) =>
+ case WRef(rname,_,_,_) if betterName(lname, rname) && !swapMap.contains(rname) =>
+ assert(!swapMap.contains(lname)) // <- Shouldn't be possible because lname is either a
+ // node declaration or the single connection to a wire or register
swapMap += (lname -> rname, rname -> lname)
case _ =>
}