Skip to content

x64: port icmp to ISLE#3886

Merged
abrown merged 4 commits into
bytecodealliance:mainfrom
abrown:isle-icmp
Mar 18, 2022
Merged

x64: port icmp to ISLE#3886
abrown merged 4 commits into
bytecodealliance:mainfrom
abrown:isle-icmp

Conversation

@abrown
Copy link
Copy Markdown
Member

@abrown abrown commented Mar 5, 2022

This change ports the lowering of the icmp instruction to ISLE.

@abrown
Copy link
Copy Markdown
Member Author

abrown commented Mar 5, 2022

@cfallin or @fitzgen: trying to port these instructions over is painful. I'm stuck on how to best lower this CMP + SETcc + SETcc sequence which involves new ways to produce and consume flags. That is what remains of the i128 lowering; the vector lowering should not be difficult.

@github-actions github-actions Bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen isle Related to the ISLE domain-specific language labels Mar 5, 2022
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 5, 2022

Subscribe to Label Action

cc @cfallin, @fitzgen

Details This issue or pull request has been labeled: "cranelift", "cranelift:area:x64", "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 .github/subscribe-to-label.json configuration file.

Learn more.

@fitzgen
Copy link
Copy Markdown
Member

fitzgen commented Mar 7, 2022

which involves new ways to produce and consume flags

Can this not use ProducesFlagsSideEffect and ConsumesFlagsTwiceReturnsValueRegs? The value regs will be invalid, but I think that should be fine.

Comment thread cranelift/codegen/src/isa/x64/inst.isle Outdated
@abrown abrown marked this pull request as ready for review March 18, 2022 17:40
Comment thread cranelift/filetests/filetests/isa/x64/simd-comparison-legalize.clif
Copy link
Copy Markdown
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thanks! Just one potential isel improvement idea below but nothing needed for correctness.

(rule (x64_and_with_flags_paired ty src1 src2)
(let ((dst WritableGpr (temp_writable_gpr)))
(ProducesFlags.ProducesFlagsSideEffect
(MInst.AluRmiR (operand_size_of_type_32_64 ty)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have support for emitting test I think, which IIRC is to and what cmp is to sub (i.e. doesn't write a dest, so wouldn't need to add to register pressure here) -- would it be possible to use that here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, that's a good point; let me do that in a follow-on PR.

@abrown abrown merged commit e92cbfb into bytecodealliance:main Mar 18, 2022
@abrown abrown deleted the isle-icmp branch March 18, 2022 18:22
@alexcrichton
Copy link
Copy Markdown
Member

I haven't looked much into the cause, but fuzzers over the weekend found this bug in this PR -- #3951

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants