diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2013-07-03 15:07:17 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2013-07-03 15:07:17 +0000 |
commit | a0aaa3552d53b20a99566ac7116063fbb31b9964 (patch) | |
tree | 72b86341e136accdba1c339230cee0f1ba5013d9 /cfrontend/Cop.v | |
parent | 18bbf6d3cfb15219c87ebc79a5dd58bf75f2b4c4 (diff) |
Treat casts int64 -> float32 as primitive operations instead of two
casts int64 -> float64 -> float32. The latter causes double rounding
errors.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2290 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cfrontend/Cop.v')
-rw-r--r-- | cfrontend/Cop.v | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cfrontend/Cop.v b/cfrontend/Cop.v index 4932bad..1148d09 100644 --- a/cfrontend/Cop.v +++ b/cfrontend/Cop.v @@ -151,10 +151,12 @@ Definition cast_int_long (si: signedness) (i: int) : int64 := | Unsigned => Int64.repr (Int.unsigned i) end. -Definition cast_long_float (si : signedness) (i: int64) : float := - match si with - | Signed => Float.floatoflong i - | Unsigned => Float.floatoflongu i +Definition cast_long_float (si: signedness) (sz: floatsize) (i: int64) : float := + match si, sz with + | Signed, F64 => Float.floatoflong i + | Unsigned, F64 => Float.floatoflongu i + | Signed, F32 => Float.singleoflong i + | Unsigned, F32 => Float.singleoflongu i end. Definition cast_float_long (si : signedness) (f: float) : option int64 := @@ -229,7 +231,7 @@ Definition sem_cast (v: val) (t1 t2: type) : option val := end | cast_case_l2f si1 sz2 => match v with - | Vlong i => Some (Vfloat (cast_float_float sz2 (cast_long_float si1 i))) + | Vlong i => Some (Vfloat (cast_long_float si1 sz2 i)) | _ => None end | cast_case_f2l si2 => |