<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 - Compilation does not end when -O3 or more is set."
   href="https://bugs.llvm.org/show_bug.cgi?id=40757">40757</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compilation does not end when -O3 or more is set.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>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>ueno.masakazu@jp.fujitsu.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When compiling the following program(<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - [llvm-gcc] [meta] Make llvm-gcc4 completely replace llvm-gcc3"
   href="show_bug.cgi?id=498">bug498</a>.c) with -O3 or more, compilation
does not end.

I think there is something wrong with Loop Strength Reduction Pass.
This problem can be avoided by the -mllvm -disable-lsr option.

* source program(<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - [llvm-gcc] [meta] Make llvm-gcc4 completely replace llvm-gcc3"
   href="show_bug.cgi?id=498">bug498</a>.c)
#include <stdio.h>
int main () {
  int i,j,l=0,m=3,n=40;
  unsigned long v1=1,v2=2,v3=3;
  int a[50][50],b[50][50];

  for (i=0; i<50; i++) {
    for (j=0; j<50; j++) {
      a[i][j]=0;
      b[i][j]=1;
    }
  }

  for(i=0;i<10;i++) {
    for (l=0; l<4; l++) {
      for(m=0; m<30; m++) {
        for(j=0;j<2;j++) {
          v3=v2 * v2;
        }
        v1=v3 - v1;
        v2=v1 - i;
        b[i][j]=a[i][j]+b[i][j];
      }
    }
  }

  printf("%lu %lu %lu %d\n",v1,v2,v3, b[0][0]);
  return 0;
}


* compile/exec log using -mllvm -disable-lsr option
$ clang -O3 <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - [llvm-gcc] [meta] Make llvm-gcc4 completely replace llvm-gcc3"
   href="show_bug.cgi?id=498">bug498</a>.c -mllvm -disable-lsr
$ ./a.out
12145924650467887591 12145924650467887582 3040934746218291456 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>