<html>
    <head>
      <base href="http://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 optimization of is_simm32 C++ function from HotSpot JVM sources"
   href="http://llvm.org/bugs/show_bug.cgi?id=18591">18591</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect optimization of is_simm32 C++ function from HotSpot JVM sources
          </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>Linux
          </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>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mikael.gerdin@oracle.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=11924" name="attach_11924" title="test case">attachment 11924</a> <a href="attachment.cgi?id=11924&action=edit" title="test case">[details]</a></span>
test case

I tried to build the OpenJDK JVM with clang++ 3.4 and discovered that the 32
bit version seems to hit an impossible assert.

I did some digging and found out that the function Assembler::is_simm32 is
incorrectly optimized, causing us to always hit the assert.

The JVM sources in question are here:
<a href="http://hg.openjdk.java.net/jdk9/hs/hotspot/file/3e2b76368121/src/share/vm/asm/assembler.hpp">http://hg.openjdk.java.net/jdk9/hs/hotspot/file/3e2b76368121/src/share/vm/asm/assembler.hpp</a>

The bug appears on -O2 and above, both with clang-3.4 and with llvm+clang trunk
as of 2014-01-23.

I've created a reduced test case (attached)

llvm-build$ Release+Asserts/bin/clang++ -O1 -m32 ~/scratch/is_simm.cc; ./a.out;
echo "Exit code: $?"
is_simm32(1) = 1
min_simm(32) <= 1 && 1 <= max_simm(32) = 1
Exit code: 0
llvm-build$ Release+Asserts/bin/clang++ -O2 -m32 ~/scratch/is_simm.cc; ./a.out;
echo "Exit code: $?"
is_simm32(1) = 0
min_simm(32) <= 1 && 1 <= max_simm(32) = 1
Exit code: 1</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>