<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 - Compiler transforming loop into an infinite loop when optimizations are enabled after r316208"
   href="https://bugs.llvm.org/show_bug.cgi?id=35087">35087</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compiler transforming loop into an infinite loop when optimizations are enabled after r316208
          </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>Windows NT
          </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>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>douglas_yung@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Recently IR Value Tracking was enabled by default in the compiler with r316208,
and in one of our tests, we noticed that after this commit, when optimizations
are enabled, the compiler is transforming a loop into an infinite loop.

Consider the following code repro.cpp:

extern void bar( int );

void foo() {
  for ( int x = 0x7ffffff0; x != -0x7ffffff0; ++x )
    bar( x );
}

When compiled using -O2 and a compiler built from r316207, the following x86
assembly is generated for the loop (it is fully unrolled):

        pushq   %rax
        .cfi_def_cfa_offset 16
        movl    $2147483632, %edi       # imm = 0x7FFFFFF0
        callq   _Z3bari
        movl    $2147483633, %edi       # imm = 0x7FFFFFF1
        callq   _Z3bari

        ...

        movl    $-2147483634, %edi      # imm = 0x8000000E
        callq   _Z3bari
        movl    $-2147483633, %edi      # imm = 0x8000000F
        popq    %rax
        jmp     _Z3bari                 # TAILCALL

When compiled using -O2 and a compiler built from r316208, the following code
is generated instead for the loop:

        movl    $2147483632, %ebx       # imm = 0x7FFFFFF0
        .p2align        4, 0x90
.LBB0_1:                                # %for.cond
                                        # =>This Inner Loop Header: Depth=1
        movl    %ebx, %edi
        callq   _Z3bari
        addl    $1, %ebx
        jmp     .LBB0_1

As can be seen, the compiler transformed the loop into an infinite loop.</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>