public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/45833] New: Unnecessary runtime versioning for aliasing
@ 2010-09-29 15:42 jakub at gcc dot gnu.org
  2010-09-30  1:59 ` [Bug tree-optimization/45833] " jakub at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-09-29 15:42 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Unnecessary runtime versioning for aliasing
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jakub@gcc.gnu.org
                CC: irar@gcc.gnu.org


union U { unsigned char c[32]; unsigned short s[16]; };

void
foo (union U *d, union U *s)
{
  int i;
  for (i = 0; i < 16; i++)
    d->s[i] += s->s[i];
}

void
bar (union U *d, union U *s)
{
  d->s[0] += s->s[0];
  d->s[1] += s->s[1];
  d->s[2] += s->s[2];
  d->s[3] += s->s[3];
  d->s[4] += s->s[4];
  d->s[5] += s->s[5];
  d->s[6] += s->s[6];
  d->s[7] += s->s[7];
  d->s[8] += s->s[8];
  d->s[9] += s->s[9];
  d->s[10] += s->s[10];
  d->s[11] += s->s[11];
  d->s[12] += s->s[12];
  d->s[13] += s->s[13];
  d->s[14] += s->s[14];
  d->s[15] += s->s[15];
}

has in foo unnecessary runtime versioning for aliasing, even when we should be
able to conclude that either d == s (but that is fine for vectorizing it, as
the result is stored after the sources are read), or d->s[0] ... d->s[15]
doesn't overlap with s->s[0] ... s->s[15].

test.c:7: note: === vect_analyze_dependences ===
test.c:7: note: dependence distance  = 0.
test.c:7: note: dependence distance == 0 between d_3(D)->s[i_14] and
d_3(D)->s[i_14]
test.c:7: note: versioning for alias required: can't determine dependence
between s_5(D)->s[i_14] and d_3(D)->s[i_14]
test.c:7: note: mark for run-time aliasing test between s_5(D)->s[i_14] and
d_3(D)->s[i_14]

In bar SLP isn't done, although when adding __restrict qualifiers it is done.


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

* [Bug tree-optimization/45833] Unnecessary runtime versioning for aliasing
  2010-09-29 15:42 [Bug tree-optimization/45833] New: Unnecessary runtime versioning for aliasing jakub at gcc dot gnu.org
@ 2010-09-30  1:59 ` jakub at gcc dot gnu.org
  2010-09-30  8:24 ` spop at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-09-30  1:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |spop at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-09-29 20:23:59 UTC ---
Maybe data-dependency needs to be extended for this (two references either
identical, or non-overlapping).


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

* [Bug tree-optimization/45833] Unnecessary runtime versioning for aliasing
  2010-09-29 15:42 [Bug tree-optimization/45833] New: Unnecessary runtime versioning for aliasing jakub at gcc dot gnu.org
  2010-09-30  1:59 ` [Bug tree-optimization/45833] " jakub at gcc dot gnu.org
@ 2010-09-30  8:24 ` spop at gcc dot gnu.org
  2014-02-19 19:49 ` rsandifo at gcc dot gnu.org
  2022-12-26  5:12 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: spop at gcc dot gnu.org @ 2010-09-30  8:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Sebastian Pop <spop at gcc dot gnu.org> 2010-09-29 22:05:35 UTC ---
(In reply to comment #1)
> Maybe data-dependency needs to be extended for this (two references either
> identical, or non-overlapping).

Correct.  Data dep analysis should not return a "don't know" relation when the
bases may overlap or cannot be analyzed, and then let the vectorizer decide
whether vectorization is safe with overlapping bases.  Probably we can have a
flag in the ddr struct for the data dependence relations with bases that cannot
be disentangled.


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

* [Bug tree-optimization/45833] Unnecessary runtime versioning for aliasing
  2010-09-29 15:42 [Bug tree-optimization/45833] New: Unnecessary runtime versioning for aliasing jakub at gcc dot gnu.org
  2010-09-30  1:59 ` [Bug tree-optimization/45833] " jakub at gcc dot gnu.org
  2010-09-30  8:24 ` spop at gcc dot gnu.org
@ 2014-02-19 19:49 ` rsandifo at gcc dot gnu.org
  2022-12-26  5:12 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2014-02-19 19:49 UTC (permalink / raw)
  To: gcc-bugs

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

rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rsandifo at gcc dot gnu.org

--- Comment #3 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Same thing without a union:

struct v { int v[4]; } __attribute__ ((aligned (4 * sizeof (int))));
void
f (struct v *x, struct v *y, struct v *z)
{
  for (int i = 0; i < 4; i++)
    x->v[i] = y->v[i] + z->v[i];
}

produces (with -msee4.2):

        leaq    16(%rsi), %rcx
        leaq    16(%rdi), %rax
        cmpq    %rcx, %rdi
        setae   %r8b
        cmpq    %rsi, %rax
        setbe   %cl
        orb     %cl, %r8b
        je      .L5
        leaq    16(%rdx), %rcx
        cmpq    %rcx, %rdi
        setae   %cl
        cmpq    %rdx, %rax
        setbe   %al
        orb     %al, %cl
        je      .L5
        vmovdqa (%rsi), %xmm0
        vpaddd  (%rdx), %xmm0, %xmm0
        vmovaps %xmm0, (%rdi)
        ret
...


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

* [Bug tree-optimization/45833] Unnecessary runtime versioning for aliasing
  2010-09-29 15:42 [Bug tree-optimization/45833] New: Unnecessary runtime versioning for aliasing jakub at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2014-02-19 19:49 ` rsandifo at gcc dot gnu.org
@ 2022-12-26  5:12 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-26  5:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45833

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to rsandifo@gcc.gnu.org from comment #3)
> Same thing without a union:
> 
> struct v { int v[4]; } __attribute__ ((aligned (4 * sizeof (int))));
> void
> f (struct v *x, struct v *y, struct v *z)
> {
>   for (int i = 0; i < 4; i++)
>     x->v[i] = y->v[i] + z->v[i];
> }

That was fixed in GCC 8.
The union case is still not fixed.

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

end of thread, other threads:[~2022-12-26  5:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-29 15:42 [Bug tree-optimization/45833] New: Unnecessary runtime versioning for aliasing jakub at gcc dot gnu.org
2010-09-30  1:59 ` [Bug tree-optimization/45833] " jakub at gcc dot gnu.org
2010-09-30  8:24 ` spop at gcc dot gnu.org
2014-02-19 19:49 ` rsandifo at gcc dot gnu.org
2022-12-26  5:12 ` pinskia 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).