<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [X86][MCA] X86 Models should declare dependency breaking idioms and optimizable register moves"
   href="https://bugs.llvm.org/show_bug.cgi?id=43837">43837</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86][MCA] X86 Models should declare dependency breaking idioms and optimizable register moves
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>llvm-mca
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>andrea.dibiagio@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>andrea.dibiagio@gmail.com, llvm-bugs@lists.llvm.org, matthew.davis@sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>With the only exception of BtVer2, X86 processor models don't describe
optimizable register moves and dependency breaking idioms for MCA.

In the past, special tablegen classes have been added just for the purpose of
describing optimizable register moves and dependency breaking instructions to
MCA.

MCA knows how to correctly simulate optimizable register moves. However, the
simulation requires explicitly knowledge from the target. At the moment, BtVer2
is the only model which describes optimizable register moves for MCA.

This is how we describe optimizable register movess in BtVer2:

```
def : IsOptimizableRegisterMove<[
  InstructionEquivalenceClass<[
    // GPR variants.
    MOV32rr, MOV64rr,

    // MMX variants.
    MMX_MOVQ64rr,

    // SSE variants.
    MOVAPSrr, MOVUPSrr,
    MOVAPDrr, MOVUPDrr,
    MOVDQArr, MOVDQUrr,

    // AVX variants.
    VMOVAPSrr, VMOVUPSrr,
    VMOVAPDrr, VMOVUPDrr,
    VMOVDQArr, VMOVDQUrr
  ], TruePred >
]>;
```

Models can further constraint register renaming via tablegen class
RegisterFile. In particular, models can limit how often move elimiation occurs
during a single cycle. On BtVer2, move elimination is only enabled for known
zero registers (i.e. registers previously cleared by a zero idiom).


--

Tablegen class `IsZeroIdiomFunction` and `IsDepBreakingFunction` can be
instantiated by scheduling models that want to teach to MCA how to identify
zero-idioms and known dependency-breaking idioms.

Currently these definitions are only present in the BtVer2 model.


Example of AVX zero-idioms on BtVer2 (Code snippet taken from
X86ScheduleBtver2.td):


```
def : IsZeroIdiomFunction<[
  // AVX Zero-idioms.
  DepBreakingClass<[
    // xmm fp variants.
    VXORPSrr, VXORPDrr, VANDNPSrr, VANDNPDrr,

    // xmm int variants.
    VPXORrr, VPANDNrr,
    VPSUBBrr, VPSUBWrr, VPSUBDrr, VPSUBQrr,
    VPSUBSBrr, VPSUBSWrr, VPSUBUSBrr, VPSUBUSWrr,
    VPCMPGTBrr, VPCMPGTWrr, VPCMPGTDrr, VPCMPGTQrr,

    // ymm variants.
    VXORPSYrr, VXORPDYrr, VANDNPSYrr, VANDNPDYrr
  ], ZeroIdiomPredicate>
]>;
```

The issue with the absence of knowledge about optimizable register moves was
recently raised in a code review upstream: <a href="https://reviews.llvm.org/D67875">https://reviews.llvm.org/D67875</a>


As I previously wrote, there is already a framework in MCA/tablegen to describe
optimizable register moves and dependency breaking instructions. However, none
of the upstream X86 models currently use it except for BtVer2.

So this bug is essentially about describing those idioms/register move
optimizations on other X86 processors.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>