diff --git a/Changes b/Changes index 986c8a9a8..e912ff79f 100644 --- a/Changes +++ b/Changes @@ -11,6 +11,8 @@ The contributors that suggested a given feature are shown in []. Thanks! *** Fix genblk naming with directly nested generate blocks, #2176. [Alexander Grobman] +**** Use gcc -Os in examples instead of -O2 for better average performance. + **** Fix undeclared VL_SHIFTR_WWQ, #2114. [Alex Solomatnikov] diff --git a/bin/verilator b/bin/verilator index 0a3beebf0..1ec4e722c 100755 --- a/bin/verilator +++ b/bin/verilator @@ -1964,19 +1964,18 @@ OPT, OPT_FAST, or OPT_SLOW lib/verilated.mk. Or, use the -CFLAGS and/or the compiler or linker. Or, just for one run, pass them on the command line to make: - make OPT_FAST="-O2 -fno-stack-protector" -f Vour.mk Vour__ALL.a + make OPT_FAST="-Os -fno-stack-protector" -f Vour.mk Vour__ALL.a OPT_FAST specifies optimizations for those programs that are part of the fast path, mostly code that is executed every cycle. OPT_SLOW specifies optimizations for slow-path files (plus tracing), which execute only rarely, yet take a long time to compile with optimization on. OPT specifies overall optimization and affects all compiles, including those -OPT_FAST and OPT_SLOW control. For best results, use OPT="-O2", and link +OPT_FAST and OPT_SLOW control. For best results, use OPT="-Os", and link with "-static". Nearly the same results can be had with much better compile times with OPT_FAST="-O1 -fstrict-aliasing". Higher optimization -such as "-O3" may help, but gcc compile times may be excessive under O3 on -even medium sized designs. Alternatively, some larger designs report -better performance using "-Os". +such as "-O2" or "-O3" may help, but gcc compile times may be excessive +under O3 on even medium sized designs. Unfortunately, using the optimizer with SystemC files can result in compiles taking several minutes. (The SystemC libraries have many little diff --git a/examples/cmake_tracing_c/CMakeLists.txt b/examples/cmake_tracing_c/CMakeLists.txt index ab5236b3c..d26932609 100644 --- a/examples/cmake_tracing_c/CMakeLists.txt +++ b/examples/cmake_tracing_c/CMakeLists.txt @@ -34,5 +34,5 @@ add_executable(example ../make_tracing_c/sim_main.cpp) # Add the Verilated circuit to the target verilate(example COVERAGE TRACE INCLUDE_DIRS "../make_tracing_c" - VERILATOR_ARGS -f ../make_tracing_c/input.vc -O2 -x-assign 0 + VERILATOR_ARGS -f ../make_tracing_c/input.vc -Os -x-assign 0 SOURCES ../make_tracing_c/top.v) diff --git a/examples/cmake_tracing_sc/CMakeLists.txt b/examples/cmake_tracing_sc/CMakeLists.txt index f2490eb6c..20a55c06e 100644 --- a/examples/cmake_tracing_sc/CMakeLists.txt +++ b/examples/cmake_tracing_sc/CMakeLists.txt @@ -41,7 +41,7 @@ add_executable(example ../make_tracing_sc/sc_main.cpp) # Add the Verilated circuit to the target verilate(example SYSTEMC COVERAGE TRACE INCLUDE_DIRS "../make_tracing_sc" - VERILATOR_ARGS -f ../make_tracing_sc/input.vc -O2 -x-assign 0 + VERILATOR_ARGS -f ../make_tracing_sc/input.vc -Os -x-assign 0 SOURCES ../make_tracing_sc/top.v) verilator_link_systemc(example) diff --git a/examples/make_protect_lib/Makefile b/examples/make_protect_lib/Makefile index 0f9f2e1a3..b2e33a283 100644 --- a/examples/make_protect_lib/Makefile +++ b/examples/make_protect_lib/Makefile @@ -34,7 +34,7 @@ VERILATOR_FLAGS = # Generate C++ VERILATOR_FLAGS += -cc # Optimize -VERILATOR_FLAGS += -O2 -x-assign 0 +VERILATOR_FLAGS += -Os -x-assign 0 # Warn abount lint issues; may not want this on less solid designs VERILATOR_FLAGS += -Wall # Make waveforms diff --git a/examples/make_tracing_c/Makefile b/examples/make_tracing_c/Makefile index f5a3b497e..a6acdc445 100644 --- a/examples/make_tracing_c/Makefile +++ b/examples/make_tracing_c/Makefile @@ -38,7 +38,7 @@ VERILATOR_FLAGS += -cc --exe # Generate makefile dependencies (not shown as complicates the Makefile) #VERILATOR_FLAGS += -MMD # Optimize -VERILATOR_FLAGS += -O2 -x-assign 0 +VERILATOR_FLAGS += -Os -x-assign 0 # Warn abount lint issues; may not want this on less solid designs VERILATOR_FLAGS += -Wall # Make waveforms diff --git a/examples/make_tracing_c/Makefile_obj b/examples/make_tracing_c/Makefile_obj index c3eb5291d..6d07eb427 100644 --- a/examples/make_tracing_c/Makefile_obj +++ b/examples/make_tracing_c/Makefile_obj @@ -38,7 +38,7 @@ endif # SystemC takes minutes to optimize, thus it is off by default. OPT_SLOW = # Fast path optimizations. Most time is spent in these classes. -OPT_FAST = -O2 -fstrict-aliasing +OPT_FAST = -Os -fstrict-aliasing #OPT_FAST = -O #OPT_FAST = diff --git a/examples/make_tracing_sc/Makefile b/examples/make_tracing_sc/Makefile index e70053c53..ded101604 100644 --- a/examples/make_tracing_sc/Makefile +++ b/examples/make_tracing_sc/Makefile @@ -38,7 +38,7 @@ VERILATOR_FLAGS += -sc --exe # Generate makefile dependencies (not shown as complicates the Makefile) #VERILATOR_FLAGS += -MMD # Optimize -VERILATOR_FLAGS += -O2 -x-assign 0 +VERILATOR_FLAGS += -Os -x-assign 0 # Warn abount lint issues; may not want this on less solid designs VERILATOR_FLAGS += -Wall # Make waveforms diff --git a/examples/make_tracing_sc/Makefile_obj b/examples/make_tracing_sc/Makefile_obj index 7c52ba627..03ffe389b 100644 --- a/examples/make_tracing_sc/Makefile_obj +++ b/examples/make_tracing_sc/Makefile_obj @@ -46,7 +46,7 @@ endif # SystemC takes minutes to optimize, thus it is off by default. OPT_SLOW = # Fast path optimizations. Most time is spent in these classes. -OPT_FAST = -O2 -fstrict-aliasing +OPT_FAST = -Os -fstrict-aliasing #OPT_FAST = -O #OPT_FAST = diff --git a/include/verilated.mk.in b/include/verilated.mk.in index e64de5e97..b00b58272 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -86,7 +86,7 @@ LDLIBS += $(VM_USER_LDLIBS) # SystemC takes minutes to optimize, thus it is off by default. #OPT_SLOW = # Fast path optimizations. Most time is spent in these classes. -#OPT_FAST = -O2 -fstrict-aliasing +#OPT_FAST = -Os -fstrict-aliasing #OPT_FAST = -O #OPT_FAST = diff --git a/test_regress/driver.pl b/test_regress/driver.pl index 24640f9c0..6e10dd113 100755 --- a/test_regress/driver.pl +++ b/test_regress/driver.pl @@ -1048,7 +1048,7 @@ sub compile { "-DTEST_VERBOSE=\"".($self->{verbose} ? 1 : 0)."\"", "-DTEST_SYSTEMC=\"" .($self->sc ? 1 : 0). "\"", "-DCMAKE_PREFIX_PATH=\"".(($ENV{SYSTEMC_INCLUDE}||$ENV{SYSTEMC}||'')."/..\""), - "-DTEST_OPT_FAST=\"" . ($param{benchmark}?"-O2":"") . "\"", + "-DTEST_OPT_FAST=\"" . ($param{benchmark} ? "-Os" : "") . "\"", "-DTEST_VERILATION=\"" . $::Opt_Verilation . "\"", ]); return 1 if $self->errors || $self->skips || $self->unsupporteds; @@ -1066,7 +1066,7 @@ sub compile { "TEST_OBJ_DIR=$self->{obj_dir}", "CPPFLAGS_DRIVER=-D".uc($self->{name}), ($self->{verbose} ? "CPPFLAGS_DRIVER2=-DTEST_VERBOSE=1":""), - ($param{benchmark}?"OPT_FAST=-O2":""), + ($param{benchmark} ? "OPT_FAST=-Os" : ""), "$self->{VM_PREFIX}", # bypass default rule, as we don't need archive ($param{make_flags}||""), ]);