@@ -711,7 +711,7 @@ ffunDecl name rty argtys =
711711ftyToTy :: FType -> Type
712712ftyToTy (FInt ITNative) = IntegerType 32
713713ftyToTy (FInt ITBig) = PointerType mpzTy (AddrSpace 0)
714−ftyToTy (FInt ty) = IntegerType (fromIntegral (itWidth ty))
714+ftyToTy (FInt ty) = IntegerType (itWidth ty)
715715ftyToTy FChar = IntegerType 32
716716ftyToTy FString = PointerType (IntegerType 8) (AddrSpace 0)
717717ftyToTy FUnit = VoidType
@@ -725,7 +725,7 @@ cgOp (LTrunc ITBig ity) [x] = do
725725 val <- inst $ simpleCall "mpz_get_ull" [nx]
726726 v <- case ity of
727727 IT64 -> return val
728− _ -> inst $ Trunc val (IntegerType . fromIntegral $ itWidth ity) []
728+ _ -> inst $ Trunc val (IntegerType $ itWidth ity) []
729729 box (FInt ity) v
730730
731731cgOp (LLt ITBig) [x,y] = mpzCmp IPred.SLT x y
@@ -742,6 +742,11 @@ cgOp (LAnd ITBig) [x,y] = mpzBin "and" x y
742742cgOp (LOr ITBig) [x,y] = mpzBin "ior" x y
743743cgOp (LXOr ITBig) [x,y] = mpzBin "xor" x y
744744
745+cgOp (LTrunc from to) [x] | itWidth from > itWidth to = do
746+ x' <- unbox (FInt from) x
747+ tx <- inst $ Trunc x' (IntegerType $ itWidth to) []
748+ box (FInt to) tx
749+
745750cgOp (LLt ity) [x,y] = iCmp ity IPred.SLT x y
746751cgOp (LLe ity) [x,y] = iCmp ity IPred.SLE x y
747752cgOp (LEq ity) [x,y] = iCmp ity IPred.EQ x y