<html>
    <head>
      <base href="https://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 --- - incorrect code generated when adding 64-bit constant to 64-bit variable"
   href="https://llvm.org/bugs/show_bug.cgi?id=28544">28544</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>incorrect code generated when adding 64-bit constant to 64-bit variable
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>markv@sassafras.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16738" name="attach_16738" title="C source demonstrating the bug">attachment 16738</a> <a href="attachment.cgi?id=16738&action=edit" title="C source demonstrating the bug">[details]</a></span>
C source demonstrating the bug

Adding a 64-bit constant value to a 64-bit referenced value generates incorrect
code when clang runs with -O1 or higher.  The test case is very simple:

    void
    f1 (unsigned long long *foo)
    {
        *foo += 0x0000000800000000LL;
    }

I compile thing with a command like the following:

    clang -S -O1 test.c

Generated code looks like this (abridged):

    pushq    %rbp
    movq    %rsp, %rbp
    subq    $-2147483648, (%rdi)    ## imm = 0xFFFFFFFF80000000
    popq    %rbp
    retq

For reference, similar code is compiled correctly:

    unsigned long long
    f2 (unsigned long long foo)
    {
        return(foo + 0x0000000800000000LL);
    }

Results in:

    pushq    %rbp
    movq    %rsp, %rbp
    movabsq    $34359738368, %rax      ## imm = 0x800000000
    addq    %rdi, %rax
    popq    %rbp
    retq

Attached file .c has these two routines.</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>