Skip to content

x64: Add shuffle cases for punpck{h,l}bw#5905

Merged
alexcrichton merged 3 commits into
bytecodealliance:mainfrom
alexcrichton:shuffle-cases
Mar 1, 2023
Merged

x64: Add shuffle cases for punpck{h,l}bw#5905
alexcrichton merged 3 commits into
bytecodealliance:mainfrom
alexcrichton:shuffle-cases

Conversation

@alexcrichton
Copy link
Copy Markdown
Member

I noticed this difference between LLVM and Cranelift for something I was looking at recently, and while it's probably not all that common I figured I'd add it here since it should be somewhat useful nevertheless.

I noticed this difference between LLVM and Cranelift for something I was
looking at recently, and while it's probably not all that common I
figured I'd add it here since it should be somewhat useful nevertheless.
Copy link
Copy Markdown
Contributor

@jameysharp jameysharp left a comment

Choose a reason for hiding this comment

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

Yup, this makes sense to me! I think one comment is wrong, but with that fixed feel free to merge.

Comment thread cranelift/codegen/src/isa/x64/lower.isle Outdated
;; Special case for the `punpckhbw` instruction which interleaves the upper
;; lanes of the two input registers.
(rule 5 (lower (shuffle a b (vec_mask_from_immediate mask)))
(if-let $true (vec_mask_is mask 8 24 9 25 10 26 11 27 12 28 13 29 14 30 15 31))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the hex literals in the filetest actually make the pattern more clear here. What would you think of replacing these decimal literals with hex?

Optionally, I suppose vec_mask_is could take a u128 instead of 16 u8s. I like the idea of not having a bazillion arguments to that function, but I'm not sure whether it's more clear than writing the bytes out separately. What do you think?

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.

Seems reasonable to me!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And now that I'm looking at that revision, it occurs to me that if you make a u128_from_vec_mask extractor instead of vec_mask_is, you can put these two rules at the same priority because ISLE will be able to tell that their different masks don't overlap. That should generate better pattern-matching code. Not super important, but would be nice.

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.

Oh good point, and that removes the need for vec_mask_is since u128_from_immediate already exists too

@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 1, 2023
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 1, 2023

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.

@alexcrichton alexcrichton enabled auto-merge March 1, 2023 20:57
@alexcrichton alexcrichton added this pull request to the merge queue Mar 1, 2023
@alexcrichton alexcrichton removed this pull request from the merge queue due to a manual request Mar 1, 2023
@alexcrichton alexcrichton enabled auto-merge March 1, 2023 21:20
@alexcrichton alexcrichton added this pull request to the merge queue Mar 1, 2023
Merged via the queue into bytecodealliance:main with commit f05babc Mar 1, 2023
@alexcrichton alexcrichton deleted the shuffle-cases branch March 1, 2023 22:21
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.

2 participants