Bug 28524

Summary: x*x in a loop folded to powf(x,2.) which prevents vectorization
Product: gcc Reporter: Francois-Xavier Coudert <fxcoudert>
Component: tree-optimizationAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: fxcoudert, gcc-bugs, rguenth
Priority: P3 Keywords: missed-optimization
Version: 4.2.0   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu Known to work:
Known to fail: Last reconfirmed:

Description Francois-Xavier Coudert 2006-07-28 10:50:17 UTC
$ cat a.c
void foo (float * restrict x, float * restrict y)
{
  int i;
  for (i = 0; i < 10000; i++)
    x[i] = y[i] * y[i];
}
$ gcc a.c -O1 -ffast-math -msse -mfpmath=sse -ftree-vectorize -ftree-vectorizer-verbose=5 -std=c99 -c

a.c:5: note: Alignment of access forced using peeling.
a.c:5: note: Vectorizing an unaligned access.
a.c:5: note: not vectorized: relevant stmt not supported: D.1353_14 =
__builtin_powf (D.1352_13, 2.0e+0)
a.c:5: note: vectorized 0 loops in function.


I find in fold-const.c:fold_binary, around line 9091, I found the following:
         /* Optimize x*x as pow(x,2.0), which is expanded as x*x.  */
Comment 1 Andrew Pinski 2006-07-28 10:51:30 UTC

*** This bug has been marked as a duplicate of 21465 ***
Comment 2 Andrew Pinski 2006-07-28 10:53:00 UTC
Richard, next time you tell someone to file a bug report, please at least look quickly at other bug reports which were filed before telling them to file a new one.  Finding the other bug was easy because the summary is correct.
Comment 3 Francois-Xavier Coudert 2006-07-28 10:55:09 UTC
I did do a bugzilla search before writing to mailing-list, searching for the error message "relevant stmt not supported" in the comment, but it looks like the error message was changed at some point.