Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIE2] Combiners for 8x8->8x8 and 8x4->4x8 matrix transposes #76

Open
wants to merge 12 commits into
base: vvandebe.shufflevector.pattern.optimization
Choose a base branch
from

Conversation

ValentijnvdBeek
Copy link
Collaborator

This merge requests adds the same framework for Shuffle Vector combinations used in #41 to the AIE2 backend. It also defines a new generator that generates the pattern used for a decent for subset of the shuffle vector modes. Concretely it matches mode 35 (4x4 -> 4x4 matrix transpose) and 29 (8x4->4x8 matrix transpose). Finally, it adds a generic opcode for the AIE vshuffle instruction.

@ValentijnvdBeek ValentijnvdBeek added llvm:globalisel Code that modifies the Global Intruction Selection vectorization Support for vector instructions llvm:instcombine Code that modifies the combiner backend:aie2 labels Jun 15, 2024
@ValentijnvdBeek ValentijnvdBeek self-assigned this Jun 15, 2024
Copy link
Collaborator

@konstantinschwarz konstantinschwarz left a comment

Choose a reason for hiding this comment

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

The shuffle modes description is difficult to read at first. Each element type and matrix dimension uses its own shuffle mode.

%1:_(<64 x s8>) = COPY $x0
%2:_(<64 x s8>) = COPY $x1
%0:_(<64 x s8>) = G_SHUFFLE_VECTOR %1:_(<64 x s8>), %2:_, shufflemask(0, 16, 32, 48, 1, 17, 33, 49, 2, 18, 34, 50, 3, 19, 35, 51, 4, 20, 36, 52, 5, 21, 37, 53, 6, 22, 38, 54, 7, 23, 39, 55, 8, 24, 40, 56, 9, 25, 41, 57, 10, 26, 42, 58, 11, 27, 43, 59, 12, 28, 44, 60, 13, 29, 45, 61, 14, 30, 46, 62, 15, 31, 47, 63)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mode 35 operates on a 8-bit element 8x8 matrix.
That would need to match shufflemask(0, 8, 16, 24, 1, 9, 17, 25, ...)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it does but vshuffle takes 1024 bytes of input. It ignores the higher bits of the input. 35 operates on a 8x8 8-bit element matrix, 64x8 vector, which is 512-bits. In the first case, those two are split into two 4x8 8-bit vectors and the second case is the "common" case where we just ignore the higher order bits.

What you propose would be a 4x8 8-bit match which is a 32x8 vector or 256-bit.

@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.shufflevector.pattern.optimization branch from 0e664aa to f872cf4 Compare June 24, 2024 16:16
@ValentijnvdBeek
Copy link
Collaborator Author

The shuffle modes description is difficult to read at first. Each element type and matrix dimension uses its own shuffle mode.

Yeah, it is a strange set of the ISA. At the moment I am orientating myself by looking at the image descriptions since from the perspective of G_SHUFFLEVECTOR I don't really care about what the original input was. I'll double check if I got that right, but being a bit more stringent on the size requirements seems prudent to me.

@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.shufflevector.pattern.optimization branch from f872cf4 to 73a92c2 Compare June 25, 2024 09:36
@ValentijnvdBeek ValentijnvdBeek changed the title [AIE2] Combiners for 4x4->4x4 and 8x4->4x8 matrix transposes [AIE2] Combiners for 8x8->8x8 and 8x4->4x8 matrix transposes Jun 25, 2024
@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.vshuffle.impl branch from be3751a to 5654047 Compare June 25, 2024 16:02
@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.shufflevector.pattern.optimization branch from 73a92c2 to e160d1c Compare June 26, 2024 11:39
@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.shufflevector.pattern.optimization branch from e160d1c to 07244e7 Compare July 15, 2024 15:06
@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.shufflevector.pattern.optimization branch from 07244e7 to 4836f6a Compare August 1, 2024 16:46
@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.vshuffle.impl branch from 5654047 to 84f3995 Compare August 2, 2024 11:22
@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.shufflevector.pattern.optimization branch 2 times, most recently from b41f4e1 to ea44d18 Compare August 7, 2024 18:27
@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.vshuffle.impl branch from 84f3995 to 5c3b1a6 Compare August 7, 2024 18:35
@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.shufflevector.pattern.optimization branch 2 times, most recently from 4c022df to b49d34c Compare August 12, 2024 10:38
@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.shufflevector.pattern.optimization branch 2 times, most recently from f855c29 to 4d6af83 Compare August 13, 2024 14:46
@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.shufflevector.pattern.optimization branch from 4d6af83 to 13cc82a Compare August 15, 2024 08:52
@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.vshuffle.impl branch 2 times, most recently from e05b018 to aec1600 Compare August 15, 2024 13:21
Comment on lines 450 to 461
---
name: concat_vector_reverse_32_512_random
legalized: false
body: |
bb.1.entry:
liveins: $wl2, $wl4
; CHECK-LABEL: name: concat_vector_reverse_32_512_random
; CHECK: liveins: $wl2, $wl4
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<8 x s32>) = COPY $wl2
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<8 x s32>) = COPY $wl4
; CHECK-NEXT: [[CONCAT_VECTORS:%[0-9]+]]:_(<16 x s32>) = G_CONCAT_VECTORS [[COPY1]](<8 x s32>), [[COPY]](<8 x s32>)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These got moved somehow, I will fix it when i get to it

@ValentijnvdBeek ValentijnvdBeek force-pushed the vvandebe.shufflevector.pattern.optimization branch 2 times, most recently from c38562a to ebe6489 Compare September 23, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:aie2 llvm:globalisel Code that modifies the Global Intruction Selection llvm:instcombine Code that modifies the combiner vectorization Support for vector instructions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants