Page 1 of 1

Fix for DSP.cpp optimization issue

Posted: Thu Jan 03, 2013 3:55 pm
by lantus
Hi there,

working on the Xbox 360 port i came across the disabled optimize pragma in DSP.cpp.

In DSP.cpp

Line 1196:

Code: Select all

//case 6: and case 7:  immediate format
OperandPool[Operands]=operand.iof.IMMEDIATE<<(operand.iof.JUSTIFY&3);


change that to

Code: Select all

//case 6: and case 7:  immediate format
OperandPool[Operands]=operand.iof.IMMEDIATE<<(~((operand.iof.JUSTIFY)+1)&3);


and Line 1299:

Code: Select all

//case 6: and case 7:  immediate format
Operand=operand.iof.IMMEDIATE<<(operand.iof.JUSTIFY&3);


change that to

Code: Select all

//case 6: and case 7:  immediate format
Operand=operand.iof.IMMEDIATE<<(~((operand.iof.JUSTIFY)+1)&3);         


You can now remove the #pragma optimize block around this code :) It will give you a nice performance boost as well

The reason why an optimized build breaks on this code is because operand.iof.JUSTIFY is a signed integer and bit shifting on a signed value can cause undetermined results. What the fix does is perform twos complement representation of the signed integer.

Re: Fix for DSP.cpp optimization issue

Posted: Fri Jan 04, 2013 8:33 pm
by BryWI
I will make sure this gets to the appropriate person a little faster. Thanks!

Re: Fix for DSP.cpp optimization issue

Posted: Sat Jan 05, 2013 6:46 pm
by Johnny
Excellent! Great fix! I'm quite happy to remove the compilation hack once and for all! I'll have this checked into the core code today.

Also, your xbox 360 emulation is looking good! I hope you share any core fixes or optimizations you come up with.