Skip to content

Commit 14d0501

Browse files
committed
Add some branch hints to main CPU loop
Helps a bit with the benchmark (from ~441 to ~442.5 MiB/s)
1 parent 3e97920 commit 14d0501

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/cpu/cpu_generic/ppc_cpu.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void ppc_cpu_run()
117117
// return;
118118
while (true) {
119119
gCPU.npc = gCPU.pc+4;
120-
if ((gCPU.pc & ~0xfff) == gCPU.effective_code_page) {
120+
if ((gCPU.pc & ~0xfff) == gCPU.effective_code_page) [[likely]] {
121121
opc = ppc_word_from_BE(*((uint32*)(&gCPU.physical_code_page[gCPU.pc & 0xfff])));
122122
//ppc_debug_hook();
123123
} else {
@@ -136,14 +136,14 @@ void ppc_cpu_run()
136136
ppc_exec_opc(opc);
137137
ops++;
138138
gCPU.ptb++;
139-
if (gCPU.pdec == 0) {
139+
if (gCPU.pdec == 0) [[unlikely]] {
140140
gCPU.exception_pending = true;
141141
gCPU.dec_exception = true;
142142
gCPU.pdec=0xffffffff*TB_TO_PTB_FACTOR;
143143
} else {
144144
gCPU.pdec--;
145145
}
146-
if ((ops & 0x3ffff)==0) {
146+
if ((ops & 0x3ffff)==0) [[unlikely]] {
147147
#ifdef EMSCRIPTEN
148148
sys_gui_cpu_ops_hook(ops);
149149
#endif
@@ -191,7 +191,7 @@ void ppc_cpu_run()
191191

192192
gCPU.pc = gCPU.npc;
193193

194-
if (gCPU.exception_pending) {
194+
if (gCPU.exception_pending) [[unlikely]] {
195195
if (gCPU.stop_exception) {
196196
gCPU.stop_exception = false;
197197
if (!gCPU.dec_exception && !gCPU.ext_exception) gCPU.exception_pending = false;

0 commit comments

Comments
 (0)