-
Bug
-
Resolution: Fixed
-
Medium
-
Code Generation Tools
-
CODEGEN-12673
-
-
-
default
-
Use --opt_level=off or avoid using volatile variables in the compare.
The C28 Compiler's saturation optimization for if/ternary max check generates incorrect results for volatile variable values above a constant max limit.
The issue occurs with:
--float_support=fpu64
--opt_level=0-4
volatile compares involving doubles and floating point constants
volatile variable's value is greater than a constant max limit
Example C code::
volatile double x_volatile; if(x_volatile > 4) x_volatile=4; x_volatile = (x_volatile > 4) ? 4 : x_volatile;
In the generated assembly, the GEQ condition code should instead be LT:
MOV32 *-SP[4],R0L MOV32 *-SP[2],R0H MOV32 R0H,*-SP[2] MOV32 R0L,*-SP[4] MINF64 R0,#16400 NOP ; [CPU_ALU] MOV32 R0H,*-SP[2],GEQ <-- Should be LT MOV32 R0L,*-SP[4],GEQ <-- Should be LT MOV32 *-SP[4],R0L MOV32 *-SP[2],R0H MOV32 R0H,*-SP[2] MOV32 R0L,*-SP[4]