[LLVMbugs] [Bug 16177] New: Loop miscompilation with -O3

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 30 02:19:59 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16177

            Bug ID: 16177
           Summary: Loop miscompilation with -O3
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: eugeni.stepanov at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ cat 1.cc
#include <stdio.h>

class S {
public:
  char x[1024];
};

S s[16];
S *p[16];

int main(void) {
  for (unsigned i = 0; i != 16; ++i) {
    p[i] = s + i;
  }
  for (unsigned i = 0; i != 16; ++i) {
    printf("%p\n", p[i]);
  }
  return 0;
}

$ clang++ -O3 1.cc -o 1
$ ./1
0x601030
0x601030
0x601830
0x601030
0x602030
0x601030
0x602830
0x601030
0x603030
0x601030
0x603830
0x601030
0x604030
0x601030
0x604830
0x601030


loop IR:
vector.body:                                      ; preds = %vector.body,
%vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %0 = getelementptr inbounds [16 x %class.S]* @s, i64 0, i64 %index
  %1 = insertelement <2 x %class.S*> undef, %class.S* %0, i32 0
  %2 = insertelement <2 x %class.S*> %1, %class.S* getelementptr ([16 x
%class.S]* @s, i64 0, i64 undef), i32 1
  %3 = getelementptr inbounds [16 x %class.S*]* @p, i64 0, i64 %index
  %4 = bitcast %class.S** %3 to <2 x %class.S*>*
  store <2 x %class.S*> %2, <2 x %class.S*>* %4, align 16
  %index.next = add i64 %index, 2
  %5 = icmp eq i64 %index.next, 16
  br i1 %5, label %for.cond2.preheader, label %vector.body


"undef" in "%2 =" line looks incorrect


Introduced in r182909.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130530/d3f097ca/attachment.html>


More information about the llvm-bugs mailing list