Skip to content

Commit

Permalink
Aarch64 - improve after lea lowering
Browse files Browse the repository at this point in the history
Summary:
This change improves the sequence generated when lowering the Vptr element of the lea
Vinstr by taking advantage of the sub immediate instruction.  This saves 1 instruction
per instance.

Before
=====
    (07) StLocRange<[0, 108)> t0:FramePtr, Uninit
        Main:
            0x52c0035c  d10043a0              sub x0, x29, #0x10 (16)
            0x52c00360  9280d9e1              movn x1, #0x6cf
            0x52c00364  8b0103a1              add x1, x29, x1
            0x52c00368  3900201f              strb wzr, [x0, #8]

After
====
    (07) StLocRange<[0, 108)> t0:FramePtr, Uninit
        Main:
            0x50400404  d10043a0              sub x0, x29, #0x10 (16)
            0x50400408  d11b43a1              sub x1, x29, #0x6d0 (1744)  //<<---
            0x5040040c  3900201f              strb wzr, [x0, #8]

This was seen approximately 300 times in hphp/test/quick/all_type_comparison_test.php
and around 1000 times in hphp/test/zend/good/ext/intl/tests/grapheme.php

The standard regression tests were run with six option sets.  No new failures were observed.
Closes #7929

Differential Revision: D5706712

Pulled By: mxw

fbshipit-source-id: 09dd2597677567a965e00992dfeb6d8121a1bc69
  • Loading branch information
swalk-cavium authored and hhvm-bot committed Feb 13, 2018
1 parent cb1de43 commit 57cf791
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hphp/runtime/vm/jit/vasm-simplify-arm.cpp
Expand Up @@ -99,6 +99,25 @@ bool simplify(Env& env, const loadb& inst, Vlabel b, size_t i) {

///////////////////////////////////////////////////////////////////////////////

bool simplify(Env& env, const ldimmq& inst, Vlabel b, size_t i) {
return if_inst<Vinstr::lea>(env, b, i + 1, [&] (const lea& ea) {
// ldimmq{s, index}; lea{base[index], d} -> lea{base[s],d}
if (!(env.use_counts[inst.d] == 1 &&
inst.s.q() <= 4095 &&
inst.s.q() >= -4095 &&
inst.d == ea.s.index &&
ea.s.disp == 0 &&
ea.s.base.isValid())) return false;

return simplify_impl(env, b, i, [&] (Vout& v) {
v << lea{ea.s.base[inst.s.l()], ea.d};
return 2;
});
});
}

///////////////////////////////////////////////////////////////////////////////

bool simplify(Env& env, const movzbl& inst, Vlabel b, size_t i) {
// movzbl{s, d}; shrli{2, s, d} --> ubfmli{2, 7, s, d}
return if_inst<Vinstr::shrli>(env, b, i + 1, [&](const shrli& sh) {
Expand Down

0 comments on commit 57cf791

Please sign in to comment.