<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 - [PowerPC] inefficient codegen for select with negative constant"
   href="https://bugs.llvm.org/show_bug.cgi?id=32105">32105</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[PowerPC] inefficient codegen for select with negative constant
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: PowerPC
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>spatel+llvm@rotateright.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is a simpler example than:
<a href="https://reviews.llvm.org/D30502">https://reviews.llvm.org/D30502</a>

define i32 @sel_with_negative_constant(i1 %cond) {
  %sel = select i1 %cond, i32 -32, i32 2
  ret i32 %sel
}

...the extension to i64 return type seems to make the simple -32 constant turn
into:

$ ./llc -o - ppcshl.ll -mtriple=powerpc64le 
...
        lis 4, 2047 ; 0x07FF (top 5 bits are clear)
        andi. 3, 3, 1
        ori 3, 4, 65535 0xFFFF
        li 4, 2
        sldi 3, 3, 5 ; 0x00000000FFFFFFE0 (-32 with top 32 bits cleared?)
        isel 3, 3, 4, 1
        blr

I'm working on DAG patches that would eliminate the isel for
select-of-constants, but the extension to i64 for negative constants seems to
be interfering on PPC64. See:
<a href="https://reviews.llvm.org/D30180">https://reviews.llvm.org/D30180</a>
...tests with -1 should have folded to almost nothing.</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>