This is an archive of the discontinued LLVM Phabricator instance.

[X86][tablgen] Consider the mnemonic when auto-generating memory folding table
ClosedPublic

Authored by skan on Mar 25 2022, 6:09 AM.

Details

Summary

Intuitively, the memory folding pair should have the same mnemonic.

This patch removes

{X86::SENDUIPI,X86::VMXON}

in the auto-generated table.
And NotMemoryFoldable for TPAUSE and CLWB can be saved.

{X86::MOVLHPSrr,X86::MOVHPSrm}
{X86::VMOVLHPSZrr,X86::VMOVHPSZ128rm}
{X86::VMOVLHPSrr,X86::VMOVHPSrm}

It seems the three pairs above are mistakenly killed.
But we can add them back manually later.

Diff Detail

Event Timeline

skan created this revision.Mar 25 2022, 6:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2022, 6:09 AM
skan requested review of this revision.Mar 25 2022, 6:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2022, 6:09 AM
skan added a comment.Mar 25 2022, 6:23 AM

As craig says, there is already a big test coverage hole on the hand-written memory folding tables. To make something easier, I have the following plan:

  1. Gradually fix the gap between auto-generated folding table and the hand-written one
  2. When the two are totally same, I will use the auto-generated table by default add a LIT test to check each entry of the table (sth like llvm/utils/update_llc_test_checks.py would be added)

Then we can prevent the possible regression in the future.

Amir added a comment.Mar 25 2022, 6:31 AM

Should this diff be split into two: one with adding getMnemonic (NFC), and the other with changes to X86FoldTablesEmitter?

skan added a comment.Mar 25 2022, 7:08 PM

Should this diff be split into two: one with adding getMnemonic (NFC), and the other with changes to X86FoldTablesEmitter?

Done

craig.topper added a comment.EditedMar 25 2022, 8:58 PM

Do you intend to replace the other cases that use NotMemoryFoldable in the .td file which was how we used to fix this issue. See the multiple cases already in X86InstrVMX.td

llvm/utils/TableGen/X86FoldTablesEmitter.cpp
281

fileds -> fields

skan added a comment.Mar 25 2022, 10:31 PM

Do you intend to replace the other cases that use NotMemoryFoldable in the .td file which was how we used to fix this issue. See the multiple cases already in X86InstrVMX.td

I can see you added them in https://reviews.llvm.org/rG66572df76eb9acf5c6b84c573541065cb29ce2ff
I think most of NotMemoryFoldable can be saved by checking the SchedRW is not WriteNop or WriteSystem. Do you mind I do it in another NFC patch?

skan updated this revision to Diff 418377.Mar 25 2022, 10:33 PM
skan marked an inline comment as done.

Rebase and fix typo

Do you intend to replace the other cases that use NotMemoryFoldable in the .td file which was how we used to fix this issue. See the multiple cases already in X86InstrVMX.td

I can see you added them in https://reviews.llvm.org/rG66572df76eb9acf5c6b84c573541065cb29ce2ff
I think most of NotMemoryFoldable can be saved by checking the SchedRW is not WriteNop or WriteSystem. Do you mind I do it in another NFC patch?

As I said I was primarily asking about the ones in X86InstrVMX.td that are the exact same issue as VMXON and SENDUIPI. I just want us to solve the same problems in the same way.

skan added a comment.Mar 25 2022, 10:41 PM

Do you intend to replace the other cases that use NotMemoryFoldable in the .td file which was how we used to fix this issue. See the multiple cases already in X86InstrVMX.td

I can see you added them in https://reviews.llvm.org/rG66572df76eb9acf5c6b84c573541065cb29ce2ff
I think most of NotMemoryFoldable can be saved by checking the SchedRW is not WriteNop or WriteSystem. Do you mind I do it in another NFC patch?

Some of system instructions have the same mnemonic, e.g VMWRITE64rr, VMWRITE64rm while they shouldn't be added into the folding table. That's why I'd like to do it in another NFC patch.

skan added a comment.Mar 25 2022, 10:43 PM

Do you intend to replace the other cases that use NotMemoryFoldable in the .td file which was how we used to fix this issue. See the multiple cases already in X86InstrVMX.td

I can see you added them in https://reviews.llvm.org/rG66572df76eb9acf5c6b84c573541065cb29ce2ff
I think most of NotMemoryFoldable can be saved by checking the SchedRW is not WriteNop or WriteSystem. Do you mind I do it in another NFC patch?

As I said I was primarily asking about the ones in X86InstrVMX.td that are the exact same issue as VMXON and SENDUIPI. I just want us to solve the same problems in the same way.

Okay, I will update the patch soon.

craig.topper added a comment.EditedMar 25 2022, 10:45 PM

Do you intend to replace the other cases that use NotMemoryFoldable in the .td file which was how we used to fix this issue. See the multiple cases already in X86InstrVMX.td

I can see you added them in https://reviews.llvm.org/rG66572df76eb9acf5c6b84c573541065cb29ce2ff
I think most of NotMemoryFoldable can be saved by checking the SchedRW is not WriteNop or WriteSystem. Do you mind I do it in another NFC patch?

As I said I was primarily asking about the ones in X86InstrVMX.td that are the exact same issue as VMXON and SENDUIPI. I just want us to solve the same problems in the same way.

Okay, I will update the patch soon.

Maybe it's not InstrVMX that has the overlap. But I remember something overlapped. It might be TPAUSE and CLWB

skan updated this revision to Diff 418378.Mar 25 2022, 10:53 PM

Remove redundant NotMemoryFoldable

skan added a comment.Mar 25 2022, 10:53 PM

Do you intend to replace the other cases that use NotMemoryFoldable in the .td file which was how we used to fix this issue. See the multiple cases already in X86InstrVMX.td

I can see you added them in https://reviews.llvm.org/rG66572df76eb9acf5c6b84c573541065cb29ce2ff
I think most of NotMemoryFoldable can be saved by checking the SchedRW is not WriteNop or WriteSystem. Do you mind I do it in another NFC patch?

As I said I was primarily asking about the ones in X86InstrVMX.td that are the exact same issue as VMXON and SENDUIPI. I just want us to solve the same problems in the same way.

Okay, I will update the patch soon.

Maybe it's not InstrVMX that has the overlap. But I remember something overlapped. It might be TPAUSE and CLWB

You're right! Done.

skan edited the summary of this revision. (Show Details)Mar 25 2022, 10:58 PM
skan edited the summary of this revision. (Show Details)Mar 25 2022, 11:16 PM
Amir accepted this revision.Mar 30 2022, 11:09 PM

Extra mnemonic check looks reasonable to me.

This revision is now accepted and ready to land.Mar 30 2022, 11:09 PM
skan added a comment.Apr 1 2022, 2:53 AM

Thanks @Amir !

Does this patch look good to you? @craig.topper