Skip to content

Ghidra is a software reverse engineering (SRE) framework

SuperH4: `fsca`: Minor performance optimization by using precomputed pi*2 constant and casted values to float before returning (for better decompilation)

LemonHazed5fd9a059bf9
diff --git a/Ghidra/Processors/SuperH4/data/languages/SuperH4.sinc b/Ghidra/Processors/SuperH4/data/languages/SuperH4.sinc
index eb86bd0040..b33f64fae4 100644
--- a/Ghidra/Processors/SuperH4/data/languages/SuperH4.sinc
+++ b/Ghidra/Processors/SuperH4/data/languages/SuperH4.sinc
@@ -1523,15 +1523,14 @@ define pcodeop cos;
fraction = fraction & FPUL; # extract sub-rotation
angle = int2float(fraction); # convert to float
- pi:4 = 0x40490fdb; # 3.1415927.. as 32-bit float
- pi2:4 = int2float(2 :4) f* pi; # multiply pi by 2 (2pi)
- angle = (pi2 f* angle) f/ int2float(65536 :4); # convert to radian
+ pi:4 = 0x40c90fdb; # 6.2831855.. as 32-bit float
+ angle = (pi f* angle) f/ int2float(65536 :4); # convert to radian
local _sin:4 = sin(angle); # call fake sin & cos
local _cos:4 = cos(angle);
- FRN_1 = _sin; # _sin goes to FR[n]
- FRN_2 = _cos; # _cos goes to FR[n+1]
+ FRN_1 = float2float(_sin); # _sin goes to FR[n]
+ FRN_2 = float2float(_cos); # _cos goes to FR[n+1]
}
# Transfer from System Register