z Systems: subtract immediate has its own range of valid immediate values (#9860)

Because it is turned into add immediate opposite in emit.mlp.
master
Xavier Leroy 2020-08-26 09:23:44 +02:00 committed by GitHub
parent 41f0522df3
commit 4c1654f135
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -400,6 +400,9 @@ Working version
- #9848, #9855: Fix double free of bytecode in toplevel
(Stephen Dolan, report by Sampsa Kiiskinen, review by Gabriel Scherer)
- #9860: wrong range constraint for subtract immediate on zSystems / s390x
(Xavier Leroy, review by Stephen Dolan)
OCaml 4.11
----------

View File

@ -80,6 +80,12 @@ method! select_operation op args dbg =
match (op, args) with
(* Z does not support immediate operands for multiply high *)
(Cmulhi, _) -> (Iintop Imulh, args)
(* sub immediate is turned into add immediate opposite,
hence the immediate range is special *)
| (Csubi, [arg; Cconst_int (n, _)]) when self#is_immediate (-n) ->
(Iintop_imm(Isub, n), [arg])
| (Csubi, _) ->
(Iintop Isub, args)
(* The and, or and xor instructions have a different range of immediate
operands than the other instructions *)
| (Cand, _) ->