[PATCH] D101124: [X86][AMX][NFC] Avoid assert for the same immidiate value

Pengfei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 22 19:09:02 PDT 2021


pengfei created this revision.
pengfei added reviewers: LuoYuanke, yubing, xiangzhangllvm, wxiao3.
Herald added a subscriber: hiraditya.
pengfei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The previous condition in the assert was over strict. We ought to allow
the same immidiate value being loaded more than once. The intention for
the assert is to check the same AMX register uses multiple different
immidiate shapes. So this fix supposes to be NFC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101124

Files:
  llvm/lib/Target/X86/X86TileConfig.cpp


Index: llvm/lib/Target/X86/X86TileConfig.cpp
===================================================================
--- llvm/lib/Target/X86/X86TileConfig.cpp
+++ llvm/lib/Target/X86/X86TileConfig.cpp
@@ -150,19 +150,23 @@
       // ... (sequence continues)
       // 55     tile7.rows Tile 7 rows.
       // 56-63  reserved, must be zero
-      int ImmCount = 0;
-      (void)ImmCount;
+      int64_t Imm = INT64_MAX;
       int Offset = IsRow ? 48 + I : 16 + I * 2;
       for (auto &DefMI : MRI.def_instructions(R)) {
         MachineBasicBlock &MBB = *DefMI.getParent();
         if (DefMI.isMoveImmediate()) {
-          // FIXME: We should handle this case in future.
-          assert(++ImmCount == 1 && "Cannot initialize with different shapes");
+          if (Imm != INT64_MAX) {
+            // FIXME: We should handle this case in future.
+            assert(Imm == DefMI.getOperand(1).getImm() &&
+                   "Cannot initialize with different shapes");
+            continue;
+          }
+          Imm = DefMI.getOperand(1).getImm();
           NewMI = addFrameReference(
                       BuildMI(MF.front(), ++ConstMI->getIterator(), DL,
                               TII->get(IsRow ? X86::MOV8mi : X86::MOV16mi)),
                       SS, Offset)
-                      .addImm(DefMI.getOperand(1).getImm());
+                      .addImm(Imm);
           ConstMI = NewMI;
           LIS.InsertMachineInstrInMaps(*NewMI);
         } else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101124.339838.patch
Type: text/x-patch
Size: 1471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210423/b027ba2a/attachment.bin>


More information about the llvm-commits mailing list