-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cranelift: add icmp-of-icmp rules for comparisons with 1 #8510
cranelift: add icmp-of-icmp rules for comparisons with 1 #8510
Conversation
744855e
to
8d6dd2c
Compare
cranelift/codegen/src/opts/icmp.isle
Outdated
(rule (simplify (eq ty | ||
(uextend_maybe _ (icmp ty cc x y)) | ||
(iconst_u _ 0))) | ||
(subsume (icmp ty (intcc_complement cc) x y))) | ||
|
||
;; eq(icmp(ty, cc, x, y), 1) == icmp(ty, cc_complement, x, y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, thanks!
@tertsdiepraam thanks for this! The tests are in |
8d6dd2c
to
27b5d2a
Compare
I've added tests both in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- thanks very much for this contribution!
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
gets simplified to
But the equivalent
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 :)