From cb433d87bf146024e6b1c35db706bc8b50a6ad16 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 12 Mar 2026 23:13:42 +0300 Subject: [PATCH] Fix short-circuit || for small integer types --- examples/short-circuit.psl | 6 +++--- libs/jit/source/arch/aarch64/compiler.cpp | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/short-circuit.psl b/examples/short-circuit.psl index bad56ff..cd2176f 100644 --- a/examples/short-circuit.psl +++ b/examples/short-circuit.psl @@ -1,9 +1,9 @@ -func g() -> u32: +func g() -> u16: return g() func h() -> bool: return h() -func test() -> u32: - return (!1u) || g() +func test() -> u16: + return 65535us || g() diff --git a/libs/jit/source/arch/aarch64/compiler.cpp b/libs/jit/source/arch/aarch64/compiler.cpp index 8165df4..3ce274a 100644 --- a/libs/jit/source/arch/aarch64/compiler.cpp +++ b/libs/jit/source/arch/aarch64/compiler.cpp @@ -480,7 +480,9 @@ namespace pslang::jit::aarch64 break; case ast::binary_operation_type::logical_or: { - builder.or_not_reg(31, 0, 1); + set_m1(1); + extend(1, arg1_type); + builder.xor_reg(0, 1, 1); std::int32_t start = pcontext.code.size(); builder.cbz(1, 0); push(0);