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] Rewrite G_CONCAT_VECTOR selection as table-gen #48

Merged
merged 3 commits into from
Jun 18, 2024

Conversation

ValentijnvdBeek
Copy link
Collaborator

Rewrites the selection code for the G_CONCAT_VECTORS opcode so that is done in tablegen instead of the C code.

@ValentijnvdBeek ValentijnvdBeek added enhancement New feature or request llvm:globalisel Code that modifies the Global Intruction Selection backend:aie Code that modifies AIE code vectorization Support for vector instructions labels May 22, 2024
def : Pat<(v16i32 (concat_vectors (v8i32 VEC256:$src0), (v8i32 VEC256:$src1))),
(v16i32 (REG_SEQUENCE VEC512, VEC256:$src0, sub_256_lo, VEC256:$src1, sub_256_hi))>;
def : Pat<(v32i32 (concat_vectors (v16i32 VEC512:$src0), (v16i32 VEC512:$src1))),
(v32i32 (REG_SEQUENCE VEC1024, VEC512:$src0, sub_512_lo, VEC512:$src1, sub_512_hi))>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL G_CONCAT_VECTOR exists. Where are such opcodes created, is this from a generic combiner that identifies a certain G_SHUFFLE_VECTOR pattern?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

G_CONCAT_VECTOR is created by the legalizer whenever it needs to combine two vectors together. So, for example, if you ask for 1024-bit vector you need to build 2 512-bit vectors and concat them together. There is also a combiner for it, which I enable in #41.

@@ -961,6 +961,22 @@ def : Concat256<int_aie2_concat_512_256_acc, ACC512, ACC256>;
def : Concat512<int_aie2_concat_1024_512_acc, ACC1024, ACC512>;
def : Concat1024<int_aie2_concat_1024_256_acc, ACC1024, ACC256>;

// concat_vector generic opcode
def : Pat<(v16i32 (concat_vectors (v8i32 VEC256:$src0), (v8i32 VEC256:$src1))),
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are patterns for CONCAT above. Can we replace the intrinsics int_aie2_concat_I512_I256 and friends with the generic ones?

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, they should be mostly be the same. Would you like me to update the intrinsics definition so that they rely on concat_vectors or just replace them out right? The former is a bit of breaking change for people that might depend on those intrinsics.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You cannot define intrinsics like that these concat_vectors cannot be on the output side of a table-gen file. So my suggestion would be just keeping it place to give a transition time and remove it later.

@SagarMaheshwari99
Copy link
Collaborator

@ValentijnvdBeek Can you check the code formatting?

@ValentijnvdBeek
Copy link
Collaborator Author

@ValentijnvdBeek Can you check the code formatting?

Yes, I rerun the job. That workflow wasn't working yet when I setup this PR

@ValentijnvdBeek ValentijnvdBeek merged commit b9f84ae into aie-public Jun 18, 2024
8 checks passed
@SagarMaheshwari99 SagarMaheshwari99 deleted the vvandebe.concat.vector.tablegen branch June 18, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:aie Code that modifies AIE code enhancement New feature or request llvm:globalisel Code that modifies the Global Intruction Selection vectorization Support for vector instructions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants