<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 - double-double constant expression evaluation can produce spurious NaN"
   href="https://bugs.llvm.org/show_bug.cgi?id=49132">49132</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>double-double constant expression evaluation can produce spurious NaN
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>bbaren@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24512" name="attach_24512" title="minimal example">attachment 24512</a> <a href="attachment.cgi?id=24512&action=edit" title="minimal example">[details]</a></span>
minimal example

When compiling for POWER (-target powerpc64le-linux-gnu), Clang can incorrectly
simplify long double (double-double) expressions to NaN:

        $ uname -m
        ppc64le
        $ cat ldbl.c
        extern int printf(const char* restrict, ...);
        int main() {
                long double a = -0x1.1e282e024debdb875f47f6c85p+1021L;
                printf("%Le\n", a + 0x1.fffffffffffff7ffffffffffff8p+1023L);
        }
        $ clang -Wall -Wextra -O1 -o ldbl ldbl.c
        $ ./ldbl
        nan

Inspecting the generated bitcode shows that Clang has statically evaluated the
double-double addition to a NaN, but by IEEE 754, adding two non-NaN inputs
should never produce a NaN output.

GCC produces the correct answer for this computation, though only when
optimizations are enabled (see
<a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99048">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99048</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>