<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - i965: Try to use LINE instructions to perform MAD with immediate arguments"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=77544">77544</a>
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>mattst88@gmail.com
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>i965: Try to use LINE instructions to perform MAD with immediate arguments
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr>

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

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mattst88@gmail.com
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/DRI/i965
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The LINE instruction performs a multiply-add instruction (a * b + c) where b
and c are immediate arguments. It reads b and c from offsets in src0 such that
you can load them (it they're representable) as a Vector-Float immediate.

I have a work-in-progress branch that implements this, and enables it on Gen 4
and 5.

<a href="http://cgit.freedesktop.org/~mattst88/mesa/log/?h=line">http://cgit.freedesktop.org/~mattst88/mesa/log/?h=line</a>

The shader-db results are promising once we allow MOV dst, VF to be CSE'd:

<Piles of shaders helped>

HURT:   shaders/gst-gl-text-download-yuy2-uyvy.frag fs8:  58 -> 59 (1.72%)
HURT:   shaders/unigine-tropics/465.shader_test fs8:      699 -> 1304 (86.55%)

LOST:   shaders/unigine-tropics/465.shader_test fs16

total instructions in shared programs: 806295 -> 803540 (-0.34%)
instructions in affected programs:     370163 -> 367408 (-0.74%)
GAINED:                                0
LOST:                                  1

Some investigation needs to happen to determine what in the world is going on
in 465.shader_test.

Follow on work:
 - We should also implement this for the vec4 backend.

 - Consider whether using mov(1) to load floats that aren't representable as VF
for LINE consumption is an improvement over not using LINE if the floats aren't
representable as VF. (Probably so?)

 - Consider whether this optimization is beneficial on newer platforms:

SNB doesn't co-issue (so MAD isn't faster than LINE) but perhaps the MOV
immediates can be reused more easily for other instructions?

Seems unlikely that IVB+ (that can co-issue) would benefit from preferring 
LINE (that can't be co-issued) over MAD (that can be co-issued).

Talk to Matt if you want to work on this.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>