From 58bec11bb5b63bc3344b5b735b4c73000c67abd3 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Fri, 1 Sep 2023 17:21:18 +0200 Subject: [PATCH] [s390x] Improve handling of negative i32 constants After https://github.com/bytecodealliance/wasmtime/pull/6850 was merged, the s390x back-end now always uses iilf instead of lhi to load negative constants, which is a small code size regression. Fix the isle predicate to get back lhi whenever possible. --- cranelift/codegen/src/isa/s390x/inst.isle | 2 +- cranelift/filetests/filetests/isa/s390x/constants.clif | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cranelift/codegen/src/isa/s390x/inst.isle b/cranelift/codegen/src/isa/s390x/inst.isle index 30e65266ef23..3eee3cb83a7a 100644 --- a/cranelift/codegen/src/isa/s390x/inst.isle +++ b/cranelift/codegen/src/isa/s390x/inst.isle @@ -2989,7 +2989,7 @@ dst)) ;; 32-bit result type, value fits in i16 -(rule 6 (imm (gpr32_ty ty) (i16_from_u64 n)) +(rule 6 (imm (gpr32_ty ty) (u32_pair _ (i16_from_u32 n))) (let ((dst WritableReg (temp_writable_reg ty)) (_ Unit (emit (MInst.Mov32SImm16 dst n)))) dst)) diff --git a/cranelift/filetests/filetests/isa/s390x/constants.clif b/cranelift/filetests/filetests/isa/s390x/constants.clif index 24a4c1f3552c..5ab94fc3beee 100644 --- a/cranelift/filetests/filetests/isa/s390x/constants.clif +++ b/cranelift/filetests/filetests/isa/s390x/constants.clif @@ -189,11 +189,11 @@ block0: ; VCode: ; block0: -; iilf %r2, 4294967295 +; lhi %r2, -1 ; br %r14 ; ; Disassembled: ; block0: ; offset 0x0 -; iilf %r2, 0xffffffff +; lhi %r2, -1 ; br %r14