Skip to content

refactor: using emit_cmp helper to refactor lowering of selection ins…#7344

Merged
cfallin merged 2 commits intobytecodealliance:mainfrom
Steven19Lee:steven/issue-5869
Oct 26, 2023
Merged

refactor: using emit_cmp helper to refactor lowering of selection ins…#7344
cfallin merged 2 commits intobytecodealliance:mainfrom
Steven19Lee:steven/issue-5869

Conversation

@Steven19Lee
Copy link
Copy Markdown
Contributor

@Steven19Lee Steven19Lee commented Oct 24, 2023

This PR implements the second part of issue #5869 .

As lowering the select instruction based on fcmp. I declare a helper function for lowering icmp-based select instruction.

@Steven19Lee Steven19Lee requested a review from a team as a code owner October 24, 2023 07:43
@Steven19Lee Steven19Lee requested review from cfallin and removed request for a team October 24, 2023 07:43
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen labels Oct 24, 2023
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.

Thanks! One formatting nit below, otherwise this seems correct.

Do you expect codegen to improve for any combination of compare and select instructions? If so, could we add a test showing that?

(rule (lower (has_type ty (select (maybe_uextend (icmp cc a @ (value_type (fits_in_64 a_ty)) b)) x y)))
(let ((size OperandSize (raw_operand_size_of_type a_ty)))
(with_flags (x64_cmp size b a) (cmove_from_values ty cc x y))))
(lower_select_icmp ty (emit_cmp cc a b ) x y))
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.

formatting nit: remove the space between b and the right-paren?

@Steven19Lee
Copy link
Copy Markdown
Contributor Author

Hi @cfallin thanks for your review, I think this change will behave the same as before, just a simple refactor to using emit_cmp to generate the same x64 code, so I do not expect any improvements.

Because I am new to both ISLE and clif IR, I might be missing some potential improvements we can make. if so please point it out to me , thanks ~

@Steven19Lee Steven19Lee requested a review from cfallin October 26, 2023 02:42
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.

Looks good, thanks! I didn't necessarily expect any codegen changes either, I was just curious if there were any intended. This looks like a pure refactor which is perfectly fine!

@cfallin cfallin added this pull request to the merge queue Oct 26, 2023
Merged via the queue into bytecodealliance:main with commit b1b37f4 Oct 26, 2023
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants