As I haven’t encountered any issues so far (I’ve only just started testing SDCC 4.6 RC1), I’m creating this thread to share my findings.
To begin with, I focused on the size of generated programs using MSXgl C library.
I compared:
SDCC 4.2 (the reference version for the library)
SDCC 4.5
SDCC 4.6 RC1
The tests were carried out using the default compilation options and without allowing the use of undocumented Z80 instructions (to ensure a consistent basis for comparison with SDCC 4.2).
Here are the size differences (in bytes) between SDCC 4.2 and 4.6:
There are two specific cases (which I will look into further), but overall, the generated code is smaller than that of version 4.2, and in some cases by a significant margin.
Compared to version 4.5, there are instances where version 4.6 performs less well, but overall, it seems to be an improvement.
Obviously, size isn’t the only indicator of the quality of the generated code… but it’s the easiest to test.
Now I’m going to run some functional tests to make sure all the test programmes work properly with version 4.6, and then I’ll test the performance.
Everything's fine for now.
Thanks to the SDCC team!
🎉
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was able to investigate the issues I had found with 4.6.0 RC2:
The crash in one of the test projects was not caused by SDCC 4.6 (the program only worked under specific timing conditions 🤦)
The significative increase in the size of two projects appears to be due to 16-bit calculations that used to go through the HL/DE registers with SDCC 4.2 and now involve numerous accesses via the IX register. Not only does this increase the program's size, but it also slows it down significantly.
I have three .ASM files in versions 4.2 and 4.6 RC2 to compare.
The programs are compiled with the default options.
Here is an example with an inline function that is much better optimized with SDCC 4.2 than with 4.6 RC.
Which command-line options did you use? Did you use --max-allocs-per-node? If yes, with which argument? Have you also tried compiling these with a higher argument for --max-allocs-per-node (not specifying it at all is equivalent to --max-allocs-per-node 3000)?
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm always using default option when comparing SDCC versions.
I tried several complexity values, and you can indeed see that while SDCC 4.6 doesn't perform very well on the TheCastle project with the default settings compared to version 4.2, its performance gradually improves as the complexity increases (where version 4.2 doesn't seem to converge).
I'm glad no serious (i.e. generation of wrong code)issues came up. The code size regression looks like it might be due to the register allocator making worse choices in your case, which in turn might be the result of it having more freedom now than in SDCC 4.2.0. The register allocator is guided by some hard rules, but also heuristics when it can't prove what is best. Those heuristics are sometimes changed a bit, but none can be perfect for all code. In general, only a higher --max-allocs-per-node argument can help (but comes at the cost of longer compile times and higher memory use during compilation).
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
As I haven’t encountered any issues so far (I’ve only just started testing SDCC 4.6 RC1), I’m creating this thread to share my findings.
To begin with, I focused on the size of generated programs using MSXgl C library.
I compared:
The tests were carried out using the default compilation options and without allowing the use of undocumented Z80 instructions (to ensure a consistent basis for comparison with SDCC 4.2).
Here are the size differences (in bytes) between SDCC 4.2 and 4.6:
There are two specific cases (which I will look into further), but overall, the generated code is smaller than that of version 4.2, and in some cases by a significant margin.
Compared to version 4.5, there are instances where version 4.6 performs less well, but overall, it seems to be an improvement.
Obviously, size isn’t the only indicator of the quality of the generated code… but it’s the easiest to test.
Now I’m going to run some functional tests to make sure all the test programmes work properly with version 4.6, and then I’ll test the performance.
Everything's fine for now.
Thanks to the SDCC team!
I was able to investigate the issues I had found with 4.6.0 RC2:
I have three .ASM files in versions 4.2 and 4.6 RC2 to compare.
The programs are compiled with the default options.
Here is an example with an inline function that is much better optimized with SDCC 4.2 than with 4.6 RC.
SDCC 4.2
SDCC 4.6 RC2
Is this a known issue?
Last edit: Aoineko 2026-06-21
Which command-line options did you use? Did you use --max-allocs-per-node? If yes, with which argument? Have you also tried compiling these with a higher argument for --max-allocs-per-node (not specifying it at all is equivalent to --max-allocs-per-node 3000)?
I'm always using default option when comparing SDCC versions.
I tried several complexity values, and you can indeed see that while SDCC 4.6 doesn't perform very well on the TheCastle project with the default settings compared to version 4.2, its performance gradually improves as the complexity increases (where version 4.2 doesn't seem to converge).
I'm glad no serious (i.e. generation of wrong code)issues came up. The code size regression looks like it might be due to the register allocator making worse choices in your case, which in turn might be the result of it having more freedom now than in SDCC 4.2.0. The register allocator is guided by some hard rules, but also heuristics when it can't prove what is best. Those heuristics are sometimes changed a bit, but none can be perfect for all code. In general, only a higher --max-allocs-per-node argument can help (but comes at the cost of longer compile times and higher memory use during compilation).