on master help sign in
Fix fixed-width integer to Integer conversions
91f4733Benjamin Saunders
src/IRTS/CodegenLLVM.hs+2−2
@@ -739,7 +739,7 @@ cgOp (LZExt from ITBig) [x] = do
739 nx <- unbox (FInt from) x
739 nx <- unbox (FInt from) x
740 nx' <- case from of
740 nx' <- case from of
741 IT64 -> return nx
741 IT64 -> return nx
742− _ -> inst $ Trunc nx (IntegerType $ itWidth from) []
742+ _ -> inst $ ZExt nx (IntegerType 64) []
743 mpz <- alloc mpzTy
743 mpz <- alloc mpzTy
744 inst' $ simpleCall "mpz_init_set_ull" [mpz, nx']
744 inst' $ simpleCall "mpz_init_set_ull" [mpz, nx']
745 box (FInt ITBig) mpz
745 box (FInt ITBig) mpz
@@ -747,7 +747,7 @@ cgOp (LSExt from ITBig) [x] = do
747 nx <- unbox (FInt from) x
747 nx <- unbox (FInt from) x
748 nx' <- case from of
748 nx' <- case from of
749 IT64 -> return nx
749 IT64 -> return nx
750− _ -> inst $ Trunc nx (IntegerType $ itWidth from) []
750+ _ -> inst $ SExt nx (IntegerType 64) []
751 mpz <- alloc mpzTy
751 mpz <- alloc mpzTy
752 inst' $ simpleCall "mpz_init_set_sll" [mpz, nx']
752 inst' $ simpleCall "mpz_init_set_sll" [mpz, nx']
753 box (FInt ITBig) mpz
753 box (FInt ITBig) mpz