public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/61938] Vectorization not happening .
       [not found] <bug-61938-4@http.gcc.gnu.org/bugzilla/>
@ 2014-07-29 18:31 ` harmeeksingh at gmail dot com
  2014-07-29 18:56 ` glisse at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: harmeeksingh at gmail dot com @ 2014-07-29 18:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from harmeeksingh at gmail dot com ---
#include <stdio.h>

#define VEC 1024

typedef long  int int64;
typedef  int int32;

void foo (int       arraysize,
          int       *__restrict  result,
          int       *__restrict  selectvector,
          int       selectelements,
          int64     *__restrict array,
          int64     compval)
{
  int k, i;
  for (k =0,i=0; i < arraysize; ++i) {
      result[k] = i; k += (array[i] == compval);
  }
}

main()
{
  int       result[VEC];
  int       selectvector[VEC];
  int       selectelements;
  int64     array[VEC];

  int k, i;
  foo(VEC, result, selectvector, VEC, array, 1);
}

Even the above does not vectorize 

gcc -fPIC -shared -DCLS=64 -ffast-math -mfpmath=sse -mmmx -msse -msse2
-ftree-vectorize -ftree-vectorizer-verbose=7 -O3 -march=native /tmp/x.c -o
/tmp/x

Analyzing loop at /tmp/x.c:17

17: not vectorized: data ref analysis failed *D.2502_9 = i_27;

/tmp/x.c:9: note: vectorized 0 loops in function.


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

* [Bug tree-optimization/61938] Vectorization not happening .
       [not found] <bug-61938-4@http.gcc.gnu.org/bugzilla/>
  2014-07-29 18:31 ` [Bug tree-optimization/61938] Vectorization not happening harmeeksingh at gmail dot com
@ 2014-07-29 18:56 ` glisse at gcc dot gnu.org
  2014-07-30  9:56 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: glisse at gcc dot gnu.org @ 2014-07-29 18:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> ---
Please show what you would like the code to look like after vectorization.


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

* [Bug tree-optimization/61938] Vectorization not happening .
       [not found] <bug-61938-4@http.gcc.gnu.org/bugzilla/>
  2014-07-29 18:31 ` [Bug tree-optimization/61938] Vectorization not happening harmeeksingh at gmail dot com
  2014-07-29 18:56 ` glisse at gcc dot gnu.org
@ 2014-07-30  9:56 ` rguenth at gcc dot gnu.org
  2014-07-30 22:25 ` harmeeksingh at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-30  9:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
The test from comment #3 has exactly the same issue - the store to result[k]
cannot be vectorized in any meaningful way.


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

* [Bug tree-optimization/61938] Vectorization not happening .
       [not found] <bug-61938-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2014-07-30  9:56 ` rguenth at gcc dot gnu.org
@ 2014-07-30 22:25 ` harmeeksingh at gmail dot com
  2014-07-31 10:23 ` rguenth at gcc dot gnu.org
  2015-10-20  9:27 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: harmeeksingh at gmail dot com @ 2014-07-30 22:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from harmeeksingh at gmail dot com ---

Equivalent code when written by hand where tmp is a intermediate array . The
compiler 
vectorizes both loops. 

  int k, i;
  /* vectorize the compares */
  for (i=0; i < arraysize; ++i) {
       tmp[i] = (array[i] == compval);
  }

  /* another loop now set the result array */
  for (k=0, i=0; i < arraysize; ++i) {
     if (tmp[i])
     {
       result[k] = i;
       k++;
     }
  }


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

* [Bug tree-optimization/61938] Vectorization not happening .
       [not found] <bug-61938-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2014-07-30 22:25 ` harmeeksingh at gmail dot com
@ 2014-07-31 10:23 ` rguenth at gcc dot gnu.org
  2015-10-20  9:27 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-31 10:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to harmeeksingh from comment #6)
>   
> Equivalent code when written by hand where tmp is a intermediate array . The
> compiler 
> vectorizes both loops. 
> 
>   int k, i;
>   /* vectorize the compares */
>   for (i=0; i < arraysize; ++i) {
>        tmp[i] = (array[i] == compval);
>   }
> 
>   /* another loop now set the result array */
>   for (k=0, i=0; i < arraysize; ++i) {
>      if (tmp[i])
>      {
>        result[k] = i;
>        k++;
>      }
>   }

I only see the first loop vectorized.

typedef long  int int64;
typedef  int int32;

void foo (int       arraysize,
          int       *__restrict  result,
          int   *__restrict tmp,
          int       *__restrict  selectvector,
          int       selectelements,
          int64     *__restrict array,
          int64     compval)
{
  int k, i;
  /* another loop now set the result array */
  for (k=0, i=0; i < arraysize; ++i) {
      if (tmp[i])
        {
          result[k] = i;
          k++;
        }
  }
}

cannot be vectorized exactly because of the said reasons.


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

* [Bug tree-optimization/61938] Vectorization not happening .
       [not found] <bug-61938-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2014-07-31 10:23 ` rguenth at gcc dot gnu.org
@ 2015-10-20  9:27 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-10-20  9:27 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Nothing to do here.


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

end of thread, other threads:[~2015-10-20  9:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-61938-4@http.gcc.gnu.org/bugzilla/>
2014-07-29 18:31 ` [Bug tree-optimization/61938] Vectorization not happening harmeeksingh at gmail dot com
2014-07-29 18:56 ` glisse at gcc dot gnu.org
2014-07-30  9:56 ` rguenth at gcc dot gnu.org
2014-07-30 22:25 ` harmeeksingh at gmail dot com
2014-07-31 10:23 ` rguenth at gcc dot gnu.org
2015-10-20  9:27 ` mpolacek 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).