fitzgen opened PR #7456 from fitzgen:depth-cost
to bytecodealliance:main
:
This means that, when the opcode cost is the same, we prefer shallow and wide
expressions to narrow and deep. For example,(a + b) + (c + d)
is preferred to
((a + b) + c) + d
. This is beneficial because it exposes more
instruction-level parallelism and shortens live ranges.Follow up PRs will add rules that take advantage of this.
fitzgen requested elliottt for a review on PR #7456.
fitzgen requested wasmtime-compiler-reviewers for a review on PR #7456.
cfallin submitted PR review.
cfallin created PR review comment:
Drive-by comment here (sorry!): it might be nice to pack this into a single
u32
; CLIF data structures in general are pretty sensitive to size in memory, or at least that's been my experience. Maybe 8 bits for depth and 24 for cost (since cost has a bit more range with deep trees, potential loop nest multipliers at some point, etc)?
fitzgen updated PR #7456.
cfallin submitted PR review:
LGTM to this as well, thanks! Will wait for #7465 to merge and this to rebase on
main
then we can merge.
fitzgen edited PR #7456:
This means that, when the opcode cost is the same, we prefer shallow and wide
expressions to narrow and deep. For example,(a + b) + (c + d)
is preferred to
((a + b) + c) + d
. This is beneficial because it exposes more
instruction-level parallelism and shortens live ranges.Follow up PRs will add rules that take advantage of this.
Depends on https://github.com/bytecodealliance/wasmtime/pull/7465
a1phyr submitted PR review.
a1phyr created PR review comment:
iter.fold(Self::zero(), |c, x| c + x)
elliottt submitted PR review:
:tada:
elliottt submitted PR review:
:tada:
elliottt created PR review comment:
Should this be strictly less-than? If the value is equal to
MAX_OP_COST
, anddepth
is255
, we'll allow constructing the specialinfinity
value.
elliottt created PR review comment:
We could skip the mask here, as we're shifting off all the bits that get zeroed by the mask.
self.0 >> Self::DEPTH_BITS
elliottt created PR review comment:
Should we only add
1
to depth when theoperand_costs
was non-empty?
fitzgen updated PR #7456.
fitzgen submitted PR review.
fitzgen created PR review comment:
Oh we could probably have an ISLE rewrite for this too!
(ishl (band a k1) k2) ==> (ishl k2) when shift_mask(k1) == k2 - 1
cc @afonso360: maybe I can nerd snipe you :)
fitzgen edited PR review comment.
fitzgen submitted PR review.
fitzgen created PR review comment:
I think it is fine to have
depth == 1
for ops without operands, and only adding1
when we have non-empty operands requires avoidingsum()
and makes the method look less elegant so I'm not gonna do it.
fitzgen updated PR #7456.
fitzgen submitted PR review.
fitzgen created PR review comment:
Reworked things a bit to make constructing infinity by accident impossible.
fitzgen updated PR #7456.
fitzgen has enabled auto merge for PR #7456.
fitzgen merged PR #7456.
Last updated: Dec 23 2024 at 12:05 UTC