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

[X86][tablgen] Auto-gen broadcast tables #73654

Merged
merged 6 commits into from
Nov 30, 2023
Merged

Conversation

KanRobert
Copy link
Contributor

@KanRobert KanRobert commented Nov 28, 2023

  1. Add TB_BCAST_SH for FP16
  2. Auto-gen 4 broadcast tables BroadcastTable[1-4]

issue: #66360

Copy link

github-actions bot commented Nov 28, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

@RKSimon
Copy link
Collaborator

RKSimon commented Nov 29, 2023

This looks to be the right direction to me - please can you update the test failures?

@KanRobert
Copy link
Contributor Author

This looks to be the right direction to me - please can you update the test failures?

Yeah. The patch is still in progress. The generated broadcast tables are incorrect and incomplete now, so we can't update the tests directly. @RKSimon

@KanRobert KanRobert changed the title [WIP][X86][tablgen] Auto-gen broadcast tables [X86][tablgen] Auto-gen broadcast tables Nov 30, 2023
@KanRobert KanRobert marked this pull request as ready for review November 30, 2023 09:28
@KanRobert KanRobert marked this pull request as draft November 30, 2023 09:39
KanRobert added a commit that referenced this pull request Nov 30, 2023
GenericDomain -> SSEPackedInt

Found by #73654
@KanRobert KanRobert marked this pull request as ready for review November 30, 2023 10:30
KanRobert added a commit that referenced this pull request Nov 30, 2023
Split NFC in #73654 into a seperate commit.
{X86::VFCMULCPHZrr, X86::VFCMULCPHZrmb, TB_BCAST_SH},
{X86::VFMULCPHZ128rr, X86::VFMULCPHZ128rmb, TB_BCAST_SH},
{X86::VFMULCPHZ256rr, X86::VFMULCPHZ256rmb, TB_BCAST_SH},
{X86::VFMULCPHZrr, X86::VFMULCPHZrmb, TB_BCAST_SH},
Copy link
Collaborator

Choose a reason for hiding this comment

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

The FMULCPH/FCMULCPH fp16 complex instructions are 32-bit broadcasts (2 x fp16) - not sure if there are others?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean TB_BCAST_SS should be used for FMULCPH/FCMULCPH or we should not add this entry at all? TB_BCAST_SH is newly added , so I am not clear how you will use it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Complex instructions use a pair of FP16 type, so it's 32-bit in fact. Non-complex is 16-bit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can safely perform this with a custom entry using TB_BCAST_SS, but it would be OK just to disable them for now (and add a TODO comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 56fd306
It's easy so I fixed it directly.

@llvm llvm deleted a comment from llvmbot Nov 30, 2023
@llvm llvm deleted a comment from llvmbot Nov 30, 2023
Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

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

A few minors I've noticed

llvm/utils/TableGen/X86FoldTablesEmitter.cpp Outdated Show resolved Hide resolved
@@ -508,19 +610,28 @@ void X86FoldTablesEmitter::updateTables(const CodeGenInstruction *RegInst,
isMemoryOperand(MemOpRec)) {
switch (I) {
case 0:
assert(!IsBroadcast && "BroadcastTable0 needs to be added");
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's stopping us adding BroadcastTable0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing. We do not add BroadcastTable0 just b/c it's empty now. If there is an entry should be in BroadcastTable0 one day, the assertion will fail and tell us to add the table.

llvm/test/TableGen/x86-fold-tables.inc Outdated Show resolved Hide resolved
llvm/test/TableGen/x86-fold-tables.inc Outdated Show resolved Hide resolved
Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

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

LGTM (with one minor) - thanks!

llvm/utils/TableGen/X86FoldTablesEmitter.cpp Outdated Show resolved Hide resolved
@KanRobert
Copy link
Contributor Author

Thanks for the review! @RKSimon @phoebewang

@KanRobert KanRobert merged commit a4e1aa2 into llvm:main Nov 30, 2023
2 of 3 checks passed
RKSimon added a commit that referenced this pull request Nov 30, 2023
@KanRobert KanRobert deleted the broadcast branch January 27, 2024 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants