Fix for DSP.cpp optimization issue
Posted: 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:
change that to
and Line 1299:
change that to
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.
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.