Commit 5b18d734 authored by John Zhang's avatar John Zhang

translate cast(LONGDOUBLE)->DOUBLE as no-op (same_as)

parent b86cd4b5
Pipeline #876 failed with stage
in 0 seconds
......@@ -1401,8 +1401,13 @@ class LL2MuMapper:
elif isinstance(SRC, mutype.MuFloatType) and isinstance(RES, mutype.MuFloatType):
if SRC == mutype.MU_FLOAT and RES == mutype.MU_DOUBLE:
optr = 'FPEXT'
elif RES == mutype.MU_DOUBLE and SRC == mutype.MU_FLOAT:
optr = 'FPTRUNC'
# this happens because rffi.LONGDOUBLE is translated as MU_DOUBLE
# in this case ignore the cast
return self._rename_to_same_as(llop)
return [self.gen_mu_convop(optr, RES, llop.args[0], llop.result)]
elif SRC == RES:
......@@ -747,3 +747,13 @@ def test_map_op_mu_meta_lst2carr():
assert [op.opname for op in muops] == ['mu_getiref', 'mu_getfieldiref', 'mu_load',
'mu_getiref', 'mu_getvarpartiref', 'mu_shiftiref']
def test_map_op_cast_longdouble_to_double():
ll2mu = LL2MuMapper()
SRC = ll2mu.map_type(rffi.LONGDOUBLE)
DST = ll2mu.map_type(rffi.DOUBLE)
llop = SpaceOperation('force_cast', [varof(SRC)], varof(DST))
muops = ll2mu.map_op(llop)
assert len(muops) == 1
assert muops[0].opname == 'same_as'
\ No newline at end of file
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