Open meithecatte opened 2 months ago
That's true, but unfortunately I can't see a low-cost of way avoiding this: one would have to ask "is this value demanded in every subtree of the domtree from this point", at every point, and move it there; in the extreme, requiring an upward-pass on the domtree. Remember that we're reconstructing code placement as we recreate the CFG, we don't have any notion that there was a single imul
in the parent block previously.
I would consider this an issue in the same category as the "instruction scheduling" general concern (#6159 / #6260): the current algorithm is working as designed and produces correct code, but better heuristics could be better.
I'm curious if you have an idea for a better algorithm here?
.clif
Test CaseSteps to Reproduce
clif-util test meow.clif
Expected Results
The
imul
stays inblock0
.Actual Results
The
imul
is needlessly duplicated betweenblock1
andblock2
.Versions and Environment
Cranelift version or commit: de29ce35982eba2060709491309ccc93b397168c (main at the time of writing)
Operating system: Linux
Architecture: x86_64