Ethernet Swindle and gcc vs clang

 There will be soon a new flavor of the swindle : The ethernet swindle


It's starting to work nicely, utltimately the goal is to use the CH32V208 that is available for ~ 4$ on aliexpress. It's basically a CH32V307 without HS usb and without fpu,  same flash, same ram (more on that later).


 LWIP is pretty big and i'm running short on both flash & ram.

While looking into it, i discovered a nice option that gcc has and clang does not

"-msave-restore"

Since the Riscv does not have stmia/ldmia style instruction, it must push and pop all registers one at a time when entering/exiting a function. That is consuming a lot of code space for short functions.

The -msave-restore creates function to save/restore , all possible variants and call them instead of manually pushing/popping registers.

Let's give it a try, baseline is clang + hw FPU:

Clang + HW FPU    255 508   (+0kB)

Clang + no FPU       257 632  (+2KB)

Clang + FPU+LTO  232 690  (-22kB)

GCC + no FPU        258 934 (+3kB)

GCC+no FPU+saverestore 244 000 (-14 kB)


LTO is the big winner but it makes the code difficult to debug and is prone to quirky behaviour.

The "-msave-restore" gives a nice 14kB decrease. Too bad it's not available for clang.     


Comments

  1. Applying for a student permit is the first official step toward getting a driver’s license in the Philippines. Many applicants often ask about the LTO student permit processing time and how long it takes before they can receive their permit. Understanding the process helps you prepare the required documents properly and avoid unnecessary delays at the Land Transportation Office (LTO).

    ReplyDelete

Post a Comment

Popular posts from this blog

Component tester with STM32 : Part 1 ADC, Resistor

INA3221, weird wiring

Fixing the INA3221