<html>
    <head>
      <base href="http://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 --- - Opt incorrectly optimizes pr41454 from gcc testsuite"
   href="http://llvm.org/bugs/show_bug.cgi?id=18927">18927</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Opt incorrectly optimizes pr41454 from gcc testsuite
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.4
          </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>opt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ihusar@fit.vutbr.cz
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12099" name="attach_12099" title="test c file">attachment 12099</a> <a href="attachment.cgi?id=12099&action=edit" title="test c file">[details]</a></span>
test c file

The code in attachment 

#define OFFS 12

int main ()
{
  int BM_tab2[OFFS];
  int *BM_tab = BM_tab2;
  int *BM_tab_base;

  BM_tab_base = BM_tab;
  BM_tab += OFFS;
  while (BM_tab_base != BM_tab)
    {
      *--BM_tab = 6;
      *--BM_tab = 6;
    }
  if (BM_tab2[0] != 6)
    abort ();
  return 0;
}

get incorrectly optimized by opt -O3 to 

; Function Attrs: nounwind uwtable
define i32 @main() #0 {
if.then:
  call void @abort() #2
  unreachable
}


Strange is that when I change OFFS to e.g. 2, 4, 6, 8, 10 then it works
correctly. Values 12, 14, 16, ... cause this test be optimized only to the
abort call. With gcc this test works fine.

I used clang and opt with -O3:

clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix</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>