<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 - Inefficient 64-bit absolute addresses in Cygwin"
   href="https://bugs.llvm.org/show_bug.cgi?id=42983">42983</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inefficient 64-bit absolute addresses in Cygwin
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>5.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>agner@agner.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Cygwin Clang v. 5.0.1 is using 64-bit absolute addresses when accessing static
data in 64-bit mode. This is inefficient because it requires an extra 10-bytes
long instruction for loading an address into a register every time it needs to
access static data.

Linux Clang v. 6.0.0 with --target=x86_64-win64-windows gives the more
efficient relative addresses, as do all other compilers.

Is this a Cygwin-only issue? I posted it to the cygwin mailing list, but they
advised me to go here.

Test case:

#include <immintrin.h>

__m128d test (__m128d a) {
    __m128d b = _mm_add_pd(a, _mm_set1_pd(1.5));
    __m128d c = _mm_mul_pd(b, _mm_set1_pd(2.5));
    return c;


Cygwin Clang assembly output:

_Z4testDv2_d:
    vmovapd    (%rcx), %xmm0
    movabsq    $.LCPI0_0, %rax
    vaddpd    (%rax), %xmm0, %xmm0
    movabsq    $.LCPI0_1, %rax
    vmulpd    (%rax), %xmm0, %xmm0
    retq 

Linux Clang assembly output with windows target:

"?test@@YAU__m128d@@U1@@Z":             # @"\01?test@@YAU__m128d@@U1@@Z"
# %bb.0:
        vmovapd (%rcx), %xmm0
        vaddpd  __xmm@3ff80000000000003ff8000000000000(%rip), %xmm0, %xmm0
        vmulpd  __xmm@40040000000000004004000000000000(%rip), %xmm0, %xmm0
        retq</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>