<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - Cannonicalize B * (uitofp i1 C) —> select C, B, 0"
   href="http://llvm.org/bugs/show_bug.cgi?id=16164">16164</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Cannonicalize B * (uitofp i1 C) —> select C, B, 0
          </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>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </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>jduprat@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I initially introduced the following inst combines in r181216:
B * (uitofp i1 C) —> select C, B, 0
A * (1 - uitofp i1 C) —> select C, 0, A
select C, 0, B + select C, A, 0 —> select C, A, B

Together these 3 changes would simplify:
A * (1 - uitofp i1 C) + B * uitofp i1 C 
down to :
select C, B, A

It was found that converting the multiplies to selects would hurt performance
on platforms with an FMA instruction where the mul would have been essentially
free.
Change r181216 thus removed the first two inst combines and instead introduced
the following transformations:

select C, B, 0 + select C, 0, A —> select C, B, A
A * (1 - uitofp i1 C) + B * uitofp i1 C —> select C, B, A

This resolves the immediate performance problem, but it is felt that the select
form is a better canonical representation of what is going on, and should
eventually be reintroduced.

Pros:
- Unambiguously represents what is going on
- Reduces users of the conversion
- Will with vectorization

Cons:
- Can prevent formation of FMAs
- The multiply will perform better than the conditional select on some ISAs

We need to address the cons in the various backends (at least ARM, ARM64 and
x86) before re-enabling the above cannonicalization.  We can then remove the
following inst combine, as it will no longer be necessary:
A * (1 - uitofp i1 C) + B * uitofp i1 C —> select C, B, A</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>