Fix for DSP.cpp optimization issue

General forum for 4DO
lantus
Posts: 1
Joined: Wed Jan 02, 2013 10:19 pm

Fix for DSP.cpp optimization issue

Postby lantus » Thu Jan 03, 2013 3:55 pm

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.
BryWI
Posts: 154
Joined: Thu Oct 27, 2011 11:35 pm

Re: Fix for DSP.cpp optimization issue

Postby BryWI » Fri Jan 04, 2013 8:33 pm

I will make sure this gets to the appropriate person a little faster. Thanks!
Johnny
Site Admin
Posts: 119
Joined: Thu Oct 27, 2011 1:50 pm

Re: Fix for DSP.cpp optimization issue

Postby Johnny » Sat Jan 05, 2013 6:46 pm

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.

Return to “General Forum”

Who is online

Users browsing this forum: No registered users and 14 guests