public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/42846]  New: GCC sometimes ignores information about pointer target alignment
@ 2010-01-22 15:12 bredelin at ucla dot edu
  2010-01-22 15:14 ` [Bug tree-optimization/42846] " bredelin at ucla dot edu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: bredelin at ucla dot edu @ 2010-01-22 15:12 UTC (permalink / raw)
  To: gcc-bugs

GCC sometimes loses alignment information.

If we declare an aligned pointer type:

// These two lines work (together)
typedef real aligned_real __attribute__((aligned(16)));
typedef const aligned_real* SSE_PTR;

Then gcc generates aligned access here:

// This function uses ALIGNED accesses
real f(SSE_PTR p, SSE_PTR q,int n)
{
  real sum = 0;
  for(int i=0; i<n;i++)
    sum += p[i] * q[i];

  return sum;
}

But not here:
real f2a(const double* p_, const double* q_,int n)
{
  SSE_PTR __restrict__ p = p_;
  SSE_PTR __restrict__ q = q_;
  real sum = 0;
  for(int i=0; i<n;i++)
    sum += p[i] * q[i];

  return sum;
}

This could matter when the user know which things are aligned.

gcc version 4.5.0 20100119 (experimental) [trunk revision 156049] (Ubuntu
20100119-0ubuntu1) 

gcc-4.5 -g -c test.C -O3 -ffast-math -msse3 -mtune=barcelona
-ftree-vectorizer-verbose=4


-- 
           Summary: GCC sometimes ignores information about pointer target
                    alignment
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bredelin at ucla dot edu
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


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


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

* [Bug tree-optimization/42846] GCC sometimes ignores information about pointer target alignment
  2010-01-22 15:12 [Bug tree-optimization/42846] New: GCC sometimes ignores information about pointer target alignment bredelin at ucla dot edu
@ 2010-01-22 15:14 ` bredelin at ucla dot edu
  2010-01-22 16:30 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: bredelin at ucla dot edu @ 2010-01-22 15:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bredelin at ucla dot edu  2010-01-22 15:14 -------
Created an attachment (id=19693)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19693&action=view)
Several simple examples for alignment in vectorization.

The notes in the file about which functions contain aligned accesses were
accurate around Dec 31, 2009.  However, they have changed, and fewer things are
aligned on Jan 22, 2010.


-- 


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


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

* [Bug tree-optimization/42846] GCC sometimes ignores information about pointer target alignment
  2010-01-22 15:12 [Bug tree-optimization/42846] New: GCC sometimes ignores information about pointer target alignment bredelin at ucla dot edu
  2010-01-22 15:14 ` [Bug tree-optimization/42846] " bredelin at ucla dot edu
@ 2010-01-22 16:30 ` rguenth at gcc dot gnu dot org
  2010-01-24  7:42 ` irar at il dot ibm dot com
  2010-01-24 11:52 ` rguenth at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-01-22 16:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2010-01-22 16:30 -------
Yep.  I always fail to see why the vectorizer doesn't use the alignment
information present in from data-ref analysis:

t.i:9: note: === vect_analyze_data_refs ===
Creating dr for *D.2752_12
...
  (res = {p_4, +, 4}_1))
        base_address: p__3(D)
        offset from base address: 0
        constant offset from base address: 0
        step: 4
        aligned to: 128
        base_object: *(const aligned_real * restrict) p__3(D)

thus the base is aligned to 128 bits, offset and constant offset are
constant zero so the vectorizer should be able to compute alignment
of all accesses.

Still it says

t.i:9: note: === vect_analyze_data_refs_alignment ===
t.i:9: note: vect_compute_data_ref_alignment:
t.i:9: note: can't force alignment of ref: *D.2752_12
t.i:9: note: vect_compute_data_ref_alignment:
t.i:9: note: can't force alignment of ref: *D.2754_16
...
t.i:9: note: Vectorizing an unaligned access.
t.i:9: note: Vectorizing an unaligned access.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |irar at gcc dot gnu dot org,
                   |                            |rguenth at gcc dot gnu dot
                   |                            |org
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2010-01-22 16:30:03
               date|                            |


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


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

* [Bug tree-optimization/42846] GCC sometimes ignores information about pointer target alignment
  2010-01-22 15:12 [Bug tree-optimization/42846] New: GCC sometimes ignores information about pointer target alignment bredelin at ucla dot edu
  2010-01-22 15:14 ` [Bug tree-optimization/42846] " bredelin at ucla dot edu
  2010-01-22 16:30 ` rguenth at gcc dot gnu dot org
@ 2010-01-24  7:42 ` irar at il dot ibm dot com
  2010-01-24 11:52 ` rguenth at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: irar at il dot ibm dot com @ 2010-01-24  7:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from irar at il dot ibm dot com  2010-01-24 07:39 -------
This has already been discussed in PR 41464.

Ira


-- 


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


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

* [Bug tree-optimization/42846] GCC sometimes ignores information about pointer target alignment
  2010-01-22 15:12 [Bug tree-optimization/42846] New: GCC sometimes ignores information about pointer target alignment bredelin at ucla dot edu
                   ` (2 preceding siblings ...)
  2010-01-24  7:42 ` irar at il dot ibm dot com
@ 2010-01-24 11:52 ` rguenth at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-01-24 11:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2010-01-24 11:52 -------


*** This bug has been marked as a duplicate of 41464 ***


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2010-01-24 11:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-22 15:12 [Bug tree-optimization/42846] New: GCC sometimes ignores information about pointer target alignment bredelin at ucla dot edu
2010-01-22 15:14 ` [Bug tree-optimization/42846] " bredelin at ucla dot edu
2010-01-22 16:30 ` rguenth at gcc dot gnu dot org
2010-01-24  7:42 ` irar at il dot ibm dot com
2010-01-24 11:52 ` rguenth at gcc dot gnu dot 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).