-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Medium
-
Code Generation Tools
-
CODEGEN-12270
-
-
-
default
-
An inlined cast from int32_t to float32_t may get an incorrect optimization.
For below cutdown C code:
inline static float32_t ftol(int32_t input){
return (float32_t)input;
}
void foo()
{
global_int32 = bar(...);
... more code needed for context
float32_t flt = ftol(global_int32);
}
The correct generated assembly should be:
MOVL XAR4,#3671270
...
MOVL XAR4,*+XAR4[0]
...
MOV32 R0H,XAR4
...
MOVL @||global_int32||,XAR4
...
I32TOF32 R0H,R0H
...
MOV32 @||flt||,R0H
However, an incorrect optimization may generate below which is invalid since the memory load was based on XAR4 which is the same register:
MOVL XAR4,#3671270
...
MOVL XAR4,*+XAR4[0]
...
MOVL @||global_int32||,XAR4
...
MOV32 R0H,*+XAR4[0] ; <--- incorrect
; above should be: MOV32 R0H,XAR4
...
I32TOF32 R0H,R0H
...
MOV32 @||flt||,R0H
Above incorrect optimization can run with --opt_level=off,0,1,2,3,4