<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 - Stack realignment produces inefficient code"
   href="https://bugs.llvm.org/show_bug.cgi?id=41318">41318</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Stack realignment produces inefficient code
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>henrik@gramner.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>-mstackrealign or __attribute__((force_align_arg_pointer)) in combination with
-mstack-alignment=32 (or larger) emits an unnecessary instruction.


Minimal test case:

void foo(void);

__attribute__((force_align_arg_pointer))
void bar(void) {
    foo();
}


-O3 -mstack-alignment=16
  <bar>:
  55                push   rbp
  48 89 e5          mov    rbp,rsp
  48 83 e4 f0       and    rsp,0xfffffffffffffff0
  e8 00 00 00 00    call   <foo>
  48 89 ec          mov    rsp,rbp
  5d                pop    rbp
  c3                ret


-O3 -mstack-alignment=32
  <bar>:
  55                push   rbp
  48 89 e5          mov    rbp,rsp
  48 83 e4 e0       and    rsp,0xffffffffffffffe0
  48 83 ec 20       sub    rsp,0x20 <- This is completely redundant
  e8 00 00 00 00    call   <foo>
  48 89 ec          mov    rsp,rbp
  5d                pop    rbp
  c3                ret


Any stack alignment value larger than 16 results in the unnecessary subtraction
seen above. GCC does not have the same issue.</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>