<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 --- - InstCombine hangs (loops forever) at -O1 or higher..."
   href="https://llvm.org/bugs/show_bug.cgi?id=27703">27703</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>InstCombine hangs (loops forever) at -O1 or higher...
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>cmtice@google.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=16352" name="attach_16352" title=".i file to be compiled to reproduce the problem.">attachment 16352</a> <a href="attachment.cgi?id=16352&action=edit" title=".i file to be compiled to reproduce the problem.">[details]</a></span>
.i file to be compiled to reproduce the problem.

On the function mem_benchmark_0 in this attached .i file, if I compile it a -O1
or -O2, clang/llvm goes into an infinite loop in inst combine.  It appears to
be adding/removing items from the worklist indefinitely, while trying to
"combine redundant instructions".  At -O0 it compiles in a matter of seconds. 
At -O2 I aborted it after 30 minutes (and I've seen it run for several hours
before being aborted).

I'm attaching the .i file and also about 10 seconds worth of output from
passing '-mllvm -debug-only=instcombine' to the compile process.

The full command to compile this is:

clang-3.9 -cc1 -triple x86_64-cros-linux-gnu -emit-obj -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name lib_mem.c
-mrelocation-model pic -pic-level 2 -pie-level 2 -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -momit-leaf-frame-pointer
-dwarf-column-info -debugger-tuning=gdb -D _FORTIFY_SOURCE=2 -D RUSAGE -D
HAVE_uint=1 -D HAVE_int64_t=1 -D HAVE_pmap_clnt_h -D HAVE_socklen_t -D
HAVE_DRAND48 -D HAVE_SCHED_SETAFFINITY=1 -O2 -ferror-limit 19 -fmessage-length
83 -stack-protector 2 -o lib_mem.o -x c lib_mem.i


This is a regression, as a 3.8 version of clang that we have works just fine on
this file.</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>