Commit c5a8946e authored by John Zhang's avatar John Zhang

fix: let force_cast(int64)->int64 = same_as, rather than TRUNC

parent 5b18d734
Pipeline #887 failed with stage
in 0 seconds
......@@ -1378,8 +1378,10 @@ class LL2MuMapper:
# of all the cases, we are casting unsigned integers in this module.
use_sext = False
optr = 'SEXT' if use_sext else 'ZEXT'
else:
elif SRC.BITS > RES.BITS:
optr = 'TRUNC'
else: # SRC.BITS == RES.BITS
return self._rename_to_same_as(llop)
return [self.gen_mu_convop(optr, RES, llop.args[0], llop.result)]
elif isinstance(SRC, mutype.MuFloatType) and isinstance(RES, mutype.MuIntType):
......
......@@ -756,4 +756,12 @@ def test_map_op_cast_longdouble_to_double():
muops = ll2mu.map_op(llop)
assert len(muops) == 1
assert muops[0].opname == 'same_as'
\ No newline at end of file
def test_map_op_force_cast_uint_to_int():
ll2mu = LL2MuMapper()
SRC = ll2mu.map_type(lltype.Unsigned)
DST = ll2mu.map_type(lltype.Signed)
llop = SpaceOperation('force_cast', [varof(SRC)], varof(DST))
muops = ll2mu.map_op(llop)
assert muops[0].opname == 'same_as'
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