Stream: git-wasmtime

Topic: wasmtime / issue #8953 x64: Missed optimization with fnms...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2024 at 11:19):

UnlimitedHummus opened issue #8953:

The PR #8888 added support for fmsub and fnmsub instructions to x64. This allows sinking loads and negations, which needed
to be executed when only the fmadd and fnmadd instructions where available. This improves code generation in most cases.
However, in cases where a value is both a sinkable load and negated, the order of those matters in the current implementation.
If the value is negated first then stored on the stack and loaded after, an fnmsub instruction could be generated, which would remove the need for explicit negation.

Feature

The fnmsub instruction should also be generated in cases where one of the multiplicands is negated first and then loaded.

Benefit

The generated code would be improved in this special case. By using the fnmsub instruction the multiplicand doesn't need to be negated first.

Implementation

There are test cases added in #8888 for adding both possible orders of negation and loading. Likely this can be achieved by adding additional rules to the lowering code. There would have to be rules for the special case, where negation happens first.


Last updated: Oct 23 2024 at 20:03 UTC