scottmcm opened PR #7654 from scottmcm:normalize-add-sub-const to bytecodealliance:main:
This PR came out of me seeing that the opt patterns were written out to handle both
(!x) + 1 == !(x) - (-1) == ineg(x)and thus being sad that every pattern including
(iadd _ 1)needed to be written again for(isub _ -1).So this takes a look at more opt patterns around
iaddandisub:
- Various combinations with
ineg, likex + -y == -y + x == -(y - x) == x - y- Avoiding subtract-a-"negative"-constant, so
(isub x 255_u8)becomes(iadd x 1_u8)(but(isub x 1)is left alone)- And removing now-unnecessary patterns in arithmetic.isle and bitops.isle, like I did in #7599
I originally had
x + -1→x - 1as well, but that regressed codegen with addressing modes -- something that had been in one x64 LEA ended up being a LEA and a SUB. So there's an interesting question about whether to turn all(isub x CONST)into(iadd x CONST), but that felt like something that would need a zulip conversation, and thus it's not included in this hopefully-simpler PR.
scottmcm requested abrown for a review on PR #7654.
scottmcm requested wasmtime-compiler-reviewers for a review on PR #7654.
github-actions[bot] commented on PR #7654:
Subscribe to Label Action
cc @cfallin, @fitzgen
<details>
This issue or pull request has been labeled: "cranelift", "isle"Thus the following users have been cc'd because of the following labels:
- cfallin: isle
- fitzgen: isle
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
alexcrichton submitted PR review:
Thanks!
alexcrichton merged PR #7654.
Last updated: Dec 06 2025 at 06:05 UTC