Commit Graph

18 Commits

Author SHA1 Message Date
Julian Seward
b1488decc4 Only create copy_nop instructions for types for which an encoding exists. Issue #779.
PR #773 detects, at reload time, `copy` instructions that copy a value from stack
slot back to the same stack slot.  It replaces them with `copy_nop` instructions
that have a null encoding (hence producing no code).

For x86_64, `copy_nop` encodings for the types I64, I32, F64 and F32 are
provided.  Unfortunately the code that detects the redundant copy doesn't
check the type of the copied value, hence leaving itself open to the danger of
creating a `copy_nop` instruction cannot be encoded (which is different from
saying it has a null encoding).

This patch:

* Expands the x86_64 set of `copy_nop` encodings to: I64 I32 I16 I8 F64 and F32

* Adds encodings for the same for x86_32, rv64 and rv32.

* In `visit_inst()` in `reload.rs`, checks the type of the copied value accordingly.

* Adds comments explaining the above.
2019-06-05 13:06:22 +02:00
iximeow
6059936113 remove rex-prefixed recipes for e9 and eb jumps
while not incorrect, the prefix has no additional semantics on these
  instructions other than taking an extra byte for the jump
2019-05-29 11:32:44 +02:00
Julian Seward
03368895fe Cranelift: Redundant stack-slot-to-stack-slot copy removal. PR#773.
This is also https://bugzilla.mozilla.org/show_bug.cgi?id=1552737.

Cranelift currently has a tendency to create redundant copies (self-copies) of
values from a stack slot back to the same stack slot.  This generates a
pointless load and store and an unnecessary register use.  The copies are
created by `visit_inst` in regalloc/reload.rs.  They appear to occur mostly,
but not exclusively, at loop heads.  It's unclear why this happens.

This patch adds a special case to `visit_inst` to find such copies.  They are
converted into a new instruction, `copy_nop`, which takes and produces the
same SSA names, so as not to break any of the SSA invariants, but which has a
zero-length encoding, hence removing the copy at emission time.

`copy_nop`s source and destination operands must be stack slots and of course
the *same* stack slot.  The verifier has been enhanced to check this, since
misuse of `copy_nop` will likely lead to hard-to-find incorrect-code bugs.

Attempts were made to write a standalone .clif test case.  But these failed
because it appears the .clif parser accepts but ignores location hints that
are stack slots.  So it's impossible to write, in clif, the exact form of
`copy` instruction that triggers the transformation.
2019-05-27 13:55:48 +02:00
Nicolas B. Pierron
72b5487563 Add x86 encoding for rotr_imm and rotl_imm. 2019-05-20 11:56:56 +02:00
Benjamin Bouvier
97ebaa6f37 Add Rust implementation and address review comments of #742; 2019-05-20 11:52:43 +02:00
bjorn3
71a345e813 Legalize fcvt_from_u/sint.f32/f64.i8/i16 2019-05-20 11:52:43 +02:00
Benjamin Bouvier
d6059d4605 [meta] Use the Rust crate for settings generation; 2019-05-03 12:01:12 +02:00
Benjamin Bouvier
6a25354520 [meta-python] Use named predicates for x86 encodings instead of anonymous predicates;
And generate those in a deterministic order that the Rust crate can
reproduce easily.
2019-05-03 12:01:12 +02:00
Benjamin Bouvier
dca168f350 [meta] Switch to the Rust crate to generate legalizations and remove Python code; 2019-05-02 10:08:53 +02:00
Benjamin Bouvier
faa9b25691 [meta-python] Simplify Var ctor since it never is given a typevar argument; 2019-04-24 10:47:26 +02:00
Benjamin Bouvier
9b156fd9bb [meta] Use the Rust crate for opcodes/inst_builder code generation; 2019-04-09 15:42:28 +02:00
Philip Craig
b74b49f7c6 Fix x86-64 encoding of uextend.i64.i8
The non-REX encoding of movzbl requires one of the ABCD registers as input.
2019-04-08 05:50:59 -07:00
Benjamin Bouvier
68bda3a42d [meta-python] Fix typos; 2019-03-27 14:43:27 +01:00
bjorn3
6267e1ded9 Implement sshr_imm.i8 (#687) 2019-02-25 19:04:32 +01:00
robojumper
851f125eda Fix bitrev intrinsic 2019-02-22 16:55:15 -08:00
Rett Berg
68479e6115 Clarify br_table
From comments in
https://github.com/CraneStation/cranelift/issues/101#issuecomment-461284555
2019-02-07 09:18:07 -08:00
Dan Gohman
9f9c306091 Fix indentation warnings reported by flake8. 2019-02-06 21:37:05 -08:00
lazypassion
747ad3c4c5 moved crates in lib/ to src/, renamed crates, modified some files' text (#660)
moved crates in lib/ to src/, renamed crates, modified some files' text (#660)
2019-01-28 15:56:54 -08:00