<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 - wrong code at -O2 on x86_64-linux-gnu"
   href="https://bugs.llvm.org/show_bug.cgi?id=45360">45360</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>wrong code at -O2 on x86_64-linux-gnu
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>qrzhang@gatech.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>It appears to be a recent regression. It happens at O2 and above. O1 works
fine.

$ clang-trunk -v
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
f6b2c003f360c3d0dcfe13d751805643f229f79b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin


$ clang-trunk abc.c ; ./a.out
0

$ clang-trunk -O2 abc.c ; ./a.out
Floating point exception (core dumped)


$ cat abc.c
int printf(const char *, ...);
int a, c, d, e, f, h, i;
unsigned b, k;
short g, j;
volatile int l;
int m() {
  for (;;) {
    j = 2;
    for (; j >= 0; j--)
      for (; g;)
        ;
    h = 0;
    for (; h <= 2; h++)
      f &= d;
    e = 0;
    for (; e <= 2; e++) {
      if (k)
        for (; l; l--)
          ;
      if (j) {
        i = f == 0 ? 0 : b % f;
        if (i)
          ;
        else
          return 1;
      } else {
        c = 0;
        for (; c != 5; c = c + 5)
          f = 0;
      }
    }
  }
}
int main() {
  m();
  printf("%X\n", a);
}</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>