Skip to content

tms320c2x: some optimizations#14911

Open
FlykeSpice wants to merge 4 commits intomamedev:masterfrom
FlykeSpice:tms32025_optimize
Open

tms320c2x: some optimizations#14911
FlykeSpice wants to merge 4 commits intomamedev:masterfrom
FlykeSpice:tms32025_optimize

Conversation

@FlykeSpice
Copy link
Contributor

@FlykeSpice FlykeSpice commented Feb 2, 2026

This is a sucessor to my previous PR #14479 after @cuavas broke it with his renaming changes

Here the benchmark results from clang-x64 build (done with -bench 300):

benchmarking victlapa...
254.33 -> 254.85 (0.52)
250.91 -> 254.92 (4.01)
251.28 -> 254.37 (3.09)
251.70 -> 254.06 (2.36)

benchmarking adillor...
148.92 -> 147.59 (-1.33)
148.62 -> 148.87 (0.25)
148.78 -> 149.23 (0.45)
146.78 -> 149.00 (2.22)

benchmarking alpinerd...
116.44 -> 115.98 (-0.46)
116.24 -> 115.92 (-0.32)
116.06 -> 116.39 (0.33)
115.86 -> 116.06 (0.20)

benchmarking cybrcomm...
165.43 -> 168.59 (3.16)
170.65 -> 172.03 (1.38)
170.15 -> 172.40 (2.25)
170.37 -> 171.26 (0.89)

benchmarking raverace...
139.77 -> 140.15 (0.38)
139.00 -> 140.47 (1.47)
138.32 -> 140.83 (2.51)
139.02 -> 139.45 (0.43)

benchmarking acedrive...
141.75 -> 141.79 (0.04)
140.69 -> 142.13 (1.44)
140.32 -> 141.50 (1.18)
141.10 -> 141.96 (0.86)

benchmarking winrun91...
244.38 -> 250.36 (5.98)
244.07 -> 249.12 (5.05)
244.93 -> 248.70 (3.77)
247.36 -> 250.57 (3.21)

benchmarking winrungp...
240.20 -> 240.21 (0.01)
234.34 -> 240.38 (6.04)
239.03 -> 240.08 (1.05)
237.82 -> 240.64 (2.82)

(The bechmarks may have been influenced by CPU throttling while running them, so they can't be 100% accurate)

Copy link
Member

@cuavas cuavas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So essentially, the optimisation is:

  • Templating GETDATA to get rid of m_mHackIgnoreARP and one test for instructions that have the “next ARP” flag set. This is probably fine, but impact would be minimal at best.
  • Getting rid of m_external_mem_access and testing m_memaccess instead. Are there potentially members of the family that would need a different test?
  • Slightly shuffling the code for handling repeated instructions. Probably fine, but once again probably very small impact.

Comment on lines -1909 to +1877
return m_tms320c2x_irq_cycles;
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is safe? what if the outer if ( (INTM == 0) && (m_opcode.w.l != 0xce00) && (m_IFR & m_imr) ) passes but none of the inner tests pass? Previously it would have returned (3*CLK). If that’s never supposed to happen, it should do something to make sure the developer know bad things have happened.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the datasheet, if an interrupt occured, one vector interrupt must be serviced, it should be impossible to fallthrough all the tests. Should I place a fatalerror right below indicating it reached a unreachable state?

@BenoitAdam94
Copy link

Hey

did tms320c5x also broke somewhere because of the renaming ?

taito jc system games seems to launch but maybe there is some errors also, i'm not sure

here are some sheets from Texas Instruments :

TMS320C2x/C2xx/C5x
Optimizing C Compiler
User’s Guide

https://www.ti.com/lit/ug/spru024e/spru024e.pdf

TMS320c5x specific :

https://www.ti.com/lit/ds/symlink/tms320lbc53s.pdf

https://www.ti.com/lit/ds/sprs030a/sprs030a.pdf

@FlykeSpice
Copy link
Contributor Author

Hey

did tms320c5x also broke somewhere because of the renaming ?

taito jc system games seems to launch but maybe there is some errors also, i'm not sure

What do you mean? No, it only "broke" my prev PR nothing else (because it was referencing the source file before the renaming).

If you getting errors it must be on your end, as I tested the games and they are working fine.

Anyway, it seems the Github Actions outage has been finally resolved and I'm gonna restart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants