tertsdiepraam opened PR #8510 from tertsdiepraam:cranelift-icmp-icmp-1
to bytecodealliance:main
:
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->Suggested by @cfallin in this zulip thread: https://bytecodealliance.zulipchat.com/#narrow/stream/217117-cranelift/topic/disassemly.20seems.20.28relatively.29.20unoptimized
The icmp-of-icmp rules only included comparisons with 0. So this
(x == y) != 0
gets simplified to
x == y
But the equivalent
(x == y) == 1
did not get simplified, even though the rules to apply are just the inverse of the rules for 0.
I've added the rules for
icmp(..) == 1
andicmp(..) != 1
and tried to add some more comments to the existing rules.I need some help to figure out how I could write a test for this, because I haven't found the tests in the codebase :)
tertsdiepraam requested cfallin for a review on PR #8510.
tertsdiepraam requested wasmtime-compiler-reviewers for a review on PR #8510.
tertsdiepraam updated PR #8510.
tertsdiepraam updated PR #8510.
KGrewal1 submitted PR review.
KGrewal1 created PR review comment:
are these comments the wrong way around (ie should this be
eq(icmp(ty, cc, x, y), 1) == icmp(ty, cc, x, y)
and similar for the documentation of the other command
?
tertsdiepraam submitted PR review.
tertsdiepraam created PR review comment:
Indeed, thanks!
cfallin commented on PR #8510:
@tertsdiepraam thanks for this! The tests are in
cranelift/filetests/filetests/
; you can find midend-optimizer-specific tests that assert on expected simplified IR inegraph/
, and tests that check execution results inruntests/
. Probably both would be good for this case?
tertsdiepraam updated PR #8510.
tertsdiepraam commented on PR #8510:
I've added tests both in
egraph/
andruntests/
and fixed up the comment. I hope it's good now.
cfallin submitted PR review:
LGTM -- thanks very much for this contribution!
cfallin has enabled auto merge for PR #8510.
cfallin merged PR #8510.
Last updated: Nov 22 2024 at 16:03 UTC