Skip to content

Commit

Permalink
[s390x] Improve handling of negative i32 constants (bytecodealliance#…
Browse files Browse the repository at this point in the history
…6952)

After bytecodealliance#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.
  • Loading branch information
uweigand authored Sep 1, 2023
1 parent 350410a commit 5e7ee8a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cranelift/codegen/src/isa/s390x/inst.isle
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions cranelift/filetests/filetests/isa/s390x/constants.clif
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5e7ee8a

Please sign in to comment.