<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 - fatal error: error in backend: Instruction Combining seems stuck in an infinite loop after 100 iterations"
   href="https://bugs.llvm.org/show_bug.cgi?id=49670">49670</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>fatal error: error in backend: Instruction Combining seems stuck in an infinite loop after 100 iterations
          </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>All
          </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>haoxintu@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi all.

Clang crashes on this valid program under -O3 only. Note that this issue only
occurs in the current trunk version of clang, clang-12 (including) downwards
versions handle this case well.

$cat small.c
#include <stdint.h>
uint8_t a, d, c, b;
void e() {
  int64_t *f = e;
  b = a ? *f : 0;
  int g = 10;
  for (; g; g--) {
    c = 0;
    for (; c <= 30; c++)
      ;
    d = 26;
    for (; d <= 42; d++) {
      int64_t *i = e;
      (a -= (a %= *i) < (c > 31)) || (b /= *i);
    }
  }
}


$clang -w -O3 small.c
fatal error: error in backend: Instruction Combining seems stuck in an infinite
loop after 100 iterations.
clang-13: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
bed9933a461e7b3d0c8c5a8fa770aa1b49802660)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/github/llvm-project/build-20210320/bin
clang-13: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/small-5d6471.c
clang-13: note: diagnostic msg: /tmp/small-5d6471.sh
clang-13: note: diagnostic msg: 

********************


$clang -v
clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
bed9933a461e7b3d0c8c5a8fa770aa1b49802660)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/github/llvm-project/build-20210320/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Selected multilib: .;@m64

By the way, I'm not sure if this is the same problem as is reported in
<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [InstCombiner] fatal error: error in backend: Instruction Combining seems stuck in an infinite loop"
   href="show_bug.cgi?id=47788">https://bugs.llvm.org/show_bug.cgi?id=47788</a>
and
<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - ICE on x86_64-linux-gnu at `-O3` (Instruction Combining seems stuck in an infinite loop after 100 iterations.)"
   href="show_bug.cgi?id=47344">https://bugs.llvm.org/show_bug.cgi?id=47344</a>
or not.

Thanks,
Haoxin
</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>