cxxrtl: speed up commits on clang.
authorwhitequark <whitequark@whitequark.org>
Mon, 21 Dec 2020 00:22:50 +0000 (00:22 +0000)
committerwhitequark <whitequark@whitequark.org>
Mon, 21 Dec 2020 02:20:30 +0000 (02:20 +0000)
On Minerva SoC SRAM compiled with clang-11, this change cuts commit
time in half (!) and overall time by 20%. When compiled with gcc-10,
there is no difference.

backends/cxxrtl/cxxrtl_backend.cc

index 9875aba60a34255f48db71ac8c29696d6cba4c29..3b2fb49856275b97187093383f4de2a79b6f69bc 100644 (file)
@@ -1702,19 +1702,19 @@ struct CxxrtlWorker {
                                        continue;
                                }
                                if (!module->get_bool_attribute(ID(cxxrtl_blackbox)) || wire->port_id != 0)
-                                       f << indent << "changed |= " << mangle(wire) << ".commit();\n";
+                                       f << indent << "if (" << mangle(wire) << ".commit()) changed = true;\n";
                        }
                        if (!module->get_bool_attribute(ID(cxxrtl_blackbox))) {
                                for (auto memory : module->memories) {
                                        if (!writable_memories[memory.second])
                                                continue;
-                                       f << indent << "changed |= " << mangle(memory.second) << ".commit();\n";
+                                       f << indent << "if (" << mangle(memory.second) << ".commit()) changed = true;\n";
                                }
                                for (auto cell : module->cells()) {
                                        if (is_internal_cell(cell->type))
                                                continue;
                                        const char *access = is_cxxrtl_blackbox_cell(cell) ? "->" : ".";
-                                       f << indent << "changed |= " << mangle(cell) << access << "commit();\n";
+                                       f << indent << "if (" << mangle(cell) << access << "commit()) changed = true;\n";
                                }
                        }
                        f << indent << "return changed;\n";