Files
sdk/runtime
Vyacheslav Egorov 34fa3c1fb5 [vm] Improve same-as-first constraint handling
All other moves generated by the register allocator to satisfy
constraints were using `PrefersRegister` for the source, but
`SameAsFirstInput` was using `Any`. This lead to situations
where hot code inside a loop would repeatedly reload a constant.
To avoid these situations switch `SameAsFirstInput` to use
`PrefersRegister` when the use occurs inside a loop.

Additionally introduce an extension of `SameAsFirstInput`:
`SameAsFirstOrSecondInput`. This new constraint allows register
allocator to reorder first and second inputs if the second one
is no longer alive after the instruction. This allows register
allocator to avoid unnecessary move.

`SameAsFirstOrSecondInput` can be used as an output constraint
for commutative binary operations on X64

Additionally this CL adds a nascent infrastructure for writing
unit tests against register allocator. See `linearscan_test.cc`.

This CL improves code quality for tight loops with binary
double operations written with constants on the left, for example:


    loop {
      doubleA = C * doubleB
    }

Before this CL `C` would be reloaded into a register immediately
before multiplication, but after this CL it will be kept in
register (if register pressure allows).

Issue https://github.com/dart-lang/sdk/issues/56705

TEST=LinearScan_TestSameAsFirstOrSecond*

Change-Id: Id8e8242a8d1c1d1b8958076f10257e21e4a00aae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385001
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-09-20 14:47:49 +00:00
..
2024-08-28 10:40:21 +00:00
2024-09-03 19:53:58 +00:00