Commit 3034a6c8 authored by Simon Marlow's avatar Simon Marlow
Browse files

floating-point fix for x86_64

  
For 32-bit float primtives like sinFloat#, we currently call the
double versions of the C library functions (sin(), cos() etc.).  It
seems more correct to call the float versions (sinf(), cosf() etc.).
This makes a difference on x86_64, I'm not entirely sure why, but this
way at least generates more consistent results and avoids extra
promotion/demotion instructions when calling these primitives.
parent 25cc1d1f
......@@ -533,19 +533,19 @@ pprCallishMachOp_for_C mop
MO_F64_Log -> ptext SLIT("log")
MO_F64_Exp -> ptext SLIT("exp")
MO_F64_Sqrt -> ptext SLIT("sqrt")
MO_F32_Pwr -> ptext SLIT("pow")
MO_F32_Sin -> ptext SLIT("sin")
MO_F32_Cos -> ptext SLIT("cos")
MO_F32_Tan -> ptext SLIT("tan")
MO_F32_Sinh -> ptext SLIT("sinh")
MO_F32_Cosh -> ptext SLIT("cosh")
MO_F32_Tanh -> ptext SLIT("tanh")
MO_F32_Asin -> ptext SLIT("asin")
MO_F32_Acos -> ptext SLIT("acos")
MO_F32_Atan -> ptext SLIT("atan")
MO_F32_Log -> ptext SLIT("log")
MO_F32_Exp -> ptext SLIT("exp")
MO_F32_Sqrt -> ptext SLIT("sqrt")
MO_F32_Pwr -> ptext SLIT("powf")
MO_F32_Sin -> ptext SLIT("sinf")
MO_F32_Cos -> ptext SLIT("cosf")
MO_F32_Tan -> ptext SLIT("tanf")
MO_F32_Sinh -> ptext SLIT("sinhf")
MO_F32_Cosh -> ptext SLIT("coshf")
MO_F32_Tanh -> ptext SLIT("tanhf")
MO_F32_Asin -> ptext SLIT("asinf")
MO_F32_Acos -> ptext SLIT("acosf")
MO_F32_Atan -> ptext SLIT("atanf")
MO_F32_Log -> ptext SLIT("logf")
MO_F32_Exp -> ptext SLIT("expf")
MO_F32_Sqrt -> ptext SLIT("sqrtf")
-- ---------------------------------------------------------------------
-- Useful #defines
......
......@@ -3083,27 +3083,32 @@ outOfLineFloatOp mop res args vols
code2 <- stmtToInstrs (CmmAssign res (demote (CmmReg tmp)))
return (code1 `appOL` code2)
where
#if i386_TARGET_ARCH
promote (x,hint) = (CmmMachOp (MO_S_Conv F32 F64) [x], hint)
demote x = CmmMachOp (MO_S_Conv F64 F32) [x]
#else
promote (x,hint) = (x,hint)
demote x = x
#endif
lbl = mkForeignLabel fn Nothing True
fn = case mop of
MO_F32_Sqrt -> FSLIT("sqrt")
MO_F32_Sin -> FSLIT("sin")
MO_F32_Cos -> FSLIT("cos")
MO_F32_Tan -> FSLIT("tan")
MO_F32_Exp -> FSLIT("exp")
MO_F32_Log -> FSLIT("log")
MO_F32_Asin -> FSLIT("asin")
MO_F32_Acos -> FSLIT("acos")
MO_F32_Atan -> FSLIT("atan")
MO_F32_Sinh -> FSLIT("sinh")
MO_F32_Cosh -> FSLIT("cosh")
MO_F32_Tanh -> FSLIT("tanh")
MO_F32_Pwr -> FSLIT("pow")
MO_F32_Sqrt -> FSLIT("sqrtf")
MO_F32_Sin -> FSLIT("sinf")
MO_F32_Cos -> FSLIT("cosf")
MO_F32_Tan -> FSLIT("tanf")
MO_F32_Exp -> FSLIT("expf")
MO_F32_Log -> FSLIT("logf")
MO_F32_Asin -> FSLIT("asinf")
MO_F32_Acos -> FSLIT("acosf")
MO_F32_Atan -> FSLIT("atanf")
MO_F32_Sinh -> FSLIT("sinhf")
MO_F32_Cosh -> FSLIT("coshf")
MO_F32_Tanh -> FSLIT("tanhf")
MO_F32_Pwr -> FSLIT("powf")
MO_F64_Sqrt -> FSLIT("sqrt")
MO_F64_Sin -> FSLIT("sin")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment