From 682295b04a5087b37da9cf3f3c4fdd1b7c992166 Mon Sep 17 00:00:00 2001 From: sofia Date: Tue, 22 Jul 2025 21:05:52 +0300 Subject: [PATCH] Fix casting from the same size of integer --- reid-llvm-lib/src/lib.rs | 11 +++++++---- reid/src/codegen.rs | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/reid-llvm-lib/src/lib.rs b/reid-llvm-lib/src/lib.rs index c616225..c8eadc2 100644 --- a/reid-llvm-lib/src/lib.rs +++ b/reid-llvm-lib/src/lib.rs @@ -629,14 +629,17 @@ impl Type { } (I32 | U32, I16 | U16 | I8 | U8) => Some(Instr::Trunc(value, other.clone())), (I16 | U16, I8 | U8) => Some(Instr::Trunc(value, other.clone())), - (U8 | I8, U16 | I16 | U32 | I32 | U64 | I64 | U128 | I128) => { + (U8 | I8, U8 | I8 | U16 | I16 | U32 | I32 | U64 | I64 | U128 | I128) => { Some(Instr::ZExt(value, other.clone())) } - (U16 | I16, U32 | I32 | U64 | I64 | U128 | I128) => { + (U16 | I16, U16 | I16 | U32 | I32 | U64 | I64 | U128 | I128) => { Some(Instr::ZExt(value, other.clone())) } - (U32 | I32, U64 | I64 | U128 | I128) => Some(Instr::ZExt(value, other.clone())), - (U64 | I64, U128 | I128) => Some(Instr::ZExt(value, other.clone())), + (U32 | I32, U32 | I32 | U64 | I64 | U128 | I128) => { + Some(Instr::ZExt(value, other.clone())) + } + (U64 | I64, U64 | I64 | U128 | I128) => Some(Instr::ZExt(value, other.clone())), + (U128 | I128, U128 | I128) => Some(Instr::ZExt(value, other.clone())), (U8 | U16 | U32 | U64 | U128, F16 | F32 | F32B | F64 | F80 | F128 | F128PPC) => { Some(Instr::UIToFP(value, other.clone())) } diff --git a/reid/src/codegen.rs b/reid/src/codegen.rs index 6a7c10d..4f1f66f 100644 --- a/reid/src/codegen.rs +++ b/reid/src/codegen.rs @@ -1085,7 +1085,8 @@ impl mir::Expression { }, (TypeKind::UserPtr(_), TypeKind::UserPtr(_)) | (TypeKind::Char, TypeKind::U8) - | (TypeKind::U8, TypeKind::Char) => Some(StackValue( + | (TypeKind::U8, TypeKind::Char) + | (TypeKind::U8, TypeKind::I8) => Some(StackValue( val.0.derive( scope .block