The code below demonstrates a missed optimization opportunity that can have an impact on code. If arrays are allocated by new(), the static alias analysis is unable to prove independency: #include <stdlib.h> int foo (void) { int *a = new int [1000]; int *b = new int [1000]; int x;
a[10] = 5; b[10] = 6; x = a[10]; return x; } =cut While if the arrays are allocated by malloc(), the independency has been proved: #include <stdlib.h> int foo (void) { int *a = (int*) malloc (sizeof(int) * 1000); int *b = (int*) malloc (sizeof(int) * 1000); int x; a[10] = 5; b[10] = 6; x = a[10]; free (a); free (b); return x; } =cut ;; Function int foo() (_Z3foov) Analyzing Edge Insertions. int foo() () { int * b; int * a; void * D.2486; void * D.2485; <bb 2>: D.2485 = malloc (4000); a = (int *) D.2485; D.2486 = malloc (4000); b = (int *) D.2486; *(a + 40) = 5; *(b + 40) = 6; free (a); free (b); return 5; } The ability to prove dependency in this kind of c++ source code can enable vectorization for many loops. -- Summary: Missed optimization in dependency analysis for arrays allocated by new() Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: victork at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35467