public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/38011]  New: vectorizer ignores alignment, useless versioning
@ 2008-11-04 14:59 David dot Monniaux at ens dot fr
  2008-11-04 15:50 ` [Bug tree-optimization/38011] " rguenth at gcc dot gnu dot org
  0 siblings, 1 reply; 4+ messages in thread
From: David dot Monniaux at ens dot fr @ 2008-11-04 14:59 UTC (permalink / raw)
  To: gcc-bugs

When compiling:

void assignMultiplyVec(double* restrict __attribute__ ((aligned (16))) a, const
double * restrict __attribute__ ((aligned (16))) b, double coef, unsigned
count) {
  for(unsigned i=0; i<count; i++) {
    a[i] = b[i]*coef;
  }
}

Using: gcc -std=c99 -march=core2 -mtune=core2 -O3 -mfpmath=sse -ftree-vectorize
-ftree-vectorizer-verbose=9

The logs show:
essai_restrict_ref.c:2: note: Alignment of access forced using versioning.
essai_restrict_ref.c:2: note: Versioning for alignment will be applied.
essai_restrict_ref.c:2: note: Vectorizing an unaligned access.
and indeed the assembly code shows a test whether operands are 16-byte aligned.

This versioning is superfluous, since variable attributes guarantee 16-byte
alignment.


-- 
           Summary: vectorizer ignores alignment, useless versioning
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: David dot Monniaux at ens dot fr
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38011


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/38011] vectorizer ignores alignment, useless versioning
  2008-11-04 14:59 [Bug c/38011] New: vectorizer ignores alignment, useless versioning David dot Monniaux at ens dot fr
@ 2008-11-04 15:50 ` rguenth at gcc dot gnu dot org
  0 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-11-04 15:50 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement
          Component|c                           |tree-optimization
           Keywords|                            |missed-optimization


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38011


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/38011] vectorizer ignores alignment, useless versioning
       [not found] <bug-38011-4@http.gcc.gnu.org/bugzilla/>
  2012-07-13  8:56 ` rguenth at gcc dot gnu.org
@ 2013-03-27 12:35 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-27 12:35 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38011

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-27 12:35:44 UTC ---
Not true - you aligned the pointer, not the data it points to.  There isn't
a good way to do that with an aligned attribute, the closest you can get at
is with

typedef double aligned_double __attribute__((aligned (16)));
void assignMultiplyVec(aligned_double* restrict a, aligned_double* restrict b,
                       double coef, unsigned count)
{
  for(unsigned i=0; i<count; i++) {
      a[i] = b[i]*coef;
  }
}

but that has the issue that a[1] is not aligned but technically you
still say so (the issue is that the array has no gaps according to
the C standard but the alignment of the element type is bigger than
its size ...).

So instead we now have an assume_aligned builtin which you can use like

void assignMultiplyVec(double* restrict a_, const double * restrict b_,
                       double coef, unsigned count)
{
  double* restrict a = __builtin_assume_aligned (a_, 16);
  double* restrict b = __builtin_assume_aligned (b_, 16);
  for(unsigned i=0; i<count; i++) {
    a[i] = b[i]*coef;
  }
}

which does not have this issue.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/38011] vectorizer ignores alignment, useless versioning
       [not found] <bug-38011-4@http.gcc.gnu.org/bugzilla/>
@ 2012-07-13  8:56 ` rguenth at gcc dot gnu.org
  2013-03-27 12:35 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-13  8:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38011

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |53947

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-13 08:56:00 UTC ---
Link to vectorizer missed-optimization meta-bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-27 12:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-04 14:59 [Bug c/38011] New: vectorizer ignores alignment, useless versioning David dot Monniaux at ens dot fr
2008-11-04 15:50 ` [Bug tree-optimization/38011] " rguenth at gcc dot gnu dot org
     [not found] <bug-38011-4@http.gcc.gnu.org/bugzilla/>
2012-07-13  8:56 ` rguenth at gcc dot gnu.org
2013-03-27 12:35 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).