<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 - [SchedModel] Missing ReadAdvance on the implicit use of EFLAGS in RM and MR variants of ADC/SBB"
   href="https://bugs.llvm.org/show_bug.cgi?id=51318">51318</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[SchedModel] Missing ReadAdvance on the implicit use of EFLAGS in RM and MR variants of ADC/SBB
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>Backend: X86
          </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>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Example:

```
adc %rax, (%rsp)
```

<span class="quote">> llvm-mca -mcpu=btver2 -timeline -iterations=2</span >

The timeline view reports this:

```
Timeline view:
                    01234
Index     0123456789     

[0,0]     DeeeeeeER .   .   adcq        %rax, (%rsp)
[1,0]     D======eeeeeeER   adcq        %rax, (%rsp)
```

The load from RSP can start execution before RAX becomes available.
So, most of the load latency can be effectively hidden.

It turns out that we do correctly set a ReadAdvance for the read of RAX.
However, we forgot to do the same for the implicit read EFLAGS.

For reference, this is how it works for normal ADDs (i.e. no carry dependency).
For ADC, the timeline should be identical.

```
Timeline view:
Index     012345678

[0,0]     DeeeeeER.   addl      4(%rsp), %eax
[0,1]     D=eeeeeER   addl      (%rsp), %eax
```</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>