<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 - Codegen regression with sign extensions"
   href="https://bugs.llvm.org/show_bug.cgi?id=50126">50126</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Codegen regression with sign extensions
          </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>Linux
          </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: ARM
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, smithp352@googlemail.com, Ties.Stuij@arm.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>struct s {
        short x, y;
};

struct s rot90(struct s p)
{
        return (struct s) { -p.y,  p.x };
}

struct s rot270(struct s p)
{
        return (struct s) {  p.y, -p.x };
}


Trunk:
rot90:                                  // @rot90
        neg     w8, w0, lsr #16
        lsl     w0, w0, #16
        bfxil   x0, x8, #0, #16
        ret
rot270:                                 // @rot270
        neg     w8, w0, lsl #16
        bfxil   x8, x0, #16, #16
        mov     x0, x8
        ret


rot90:                                  // @rot90
        neg     w8, w0, lsr #16
        bfi     w8, w0, #16, #16
        mov     x0, x8
        ret
rot270:                                 // @rot270
        ubfx    x8, x0, #16, #16
        sub     w0, w8, w0, lsl #16
        ret

Maybe ideal codegen?:

rot90:
            mov     w1, w0
            neg     w0, w1, asr 16
            bfi     w0, w1, 16, 16
            ret
rot270:
            neg     w1, w0
            extr    w0, w1, w0, 16
            ret

See it live:
<a href="https://gcc.godbolt.org/z/4c4ds58v6">https://gcc.godbolt.org/z/4c4ds58v6</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>