diff options
| author | Jack Koenig | 2017-05-25 12:41:19 -0700 |
|---|---|---|
| committer | GitHub | 2017-05-25 12:41:19 -0700 |
| commit | c7c578f34f4fbd3bb987593ffdccdfb6b356b9f7 (patch) | |
| tree | 240aceacee4f9c2c7200989a3a1f773430c558ec | |
| parent | 87a5a84130207abee6ed85dcd6d0744ed180f686 (diff) | |
Fix performance bug in ZeroWidth (#594)
We were recursing on Types of Expressions which not only is super inefficient
(especially since we are already calling InferTypes afterward), but also
duplicates each of the Type objects that need changing.
| -rw-r--r-- | src/main/scala/firrtl/passes/ZeroWidth.scala | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/main/scala/firrtl/passes/ZeroWidth.scala b/src/main/scala/firrtl/passes/ZeroWidth.scala index 2472a0e5..6d7766d1 100644 --- a/src/main/scala/firrtl/passes/ZeroWidth.scala +++ b/src/main/scala/firrtl/passes/ZeroWidth.scala @@ -40,15 +40,10 @@ object ZeroWidth extends Transform { case VectorType(t, size) => removeZero(t) map (VectorType(_, size)) case x => Some(x) } - private def onExp(e: Expression): Expression = removeZero(e.tpe) match { - case None => e.tpe match { - case UIntType(x) => UIntLiteral(ZERO, IntWidth(BigInt(1))) - case SIntType(x) => SIntLiteral(ZERO, IntWidth(BigInt(1))) - case _ => throwInternalError - } - case Some(t) => - def replaceType(x: Type): Type = t - (e map replaceType) map onExp + private def onExp(e: Expression): Expression = e.tpe match { + case UIntType(IntWidth(ZERO)) => UIntLiteral(ZERO, IntWidth(BigInt(1))) + case SIntType(IntWidth(ZERO)) => SIntLiteral(ZERO, IntWidth(BigInt(1))) + case other => e map onExp } private def onStmt(renames: RenameMap)(s: Statement): Statement = s match { case (_: DefWire| _: DefRegister| _: DefMemory) => |
