;; or(x, C) + (-C) --> and(x, ~C)
(rule
(simplify (iadd ty
(bor ty x (iconst_s ty n))
(iconst_s ty m)))
(if-let m (i64_checked_neg n))
(band ty x (iconst ty (imm64_masked ty (i64_cast_unsigned (i64_not n))))))
Hi, looking at this simplify rule, I realized there can be more than one interpretation of this rule.
Does m in the if-let clause shadow the binding of m in the LHS pattern, or
does it checks m is actually a negation of n?
I wanna know what is the expected behavior of ISLE.
I think this should treat m as already-bound and thus check for equality -- I say this based on the reused bindings map here. I haven't actually tried though -- it would be good to look at the generated code to ensure this is what's happening.
I think that let allows shadowing but if-let does not. I have been annoyed by this in the past. I didn't ever consider if this was intentional to allow for equality checks with already-bound variables however
Last updated: Dec 06 2025 at 06:05 UTC