public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "alalaw01 at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/57558] Loop not vectorized if iteration count could be infinite
Date: Fri, 25 Sep 2015 13:49:00 -0000	[thread overview]
Message-ID: <bug-57558-4-CZWL024MeR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-57558-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from alalaw01 at gcc dot gnu.org ---
Here's another example, extracted from another benchmark - it vectorizes if
INDEX is defined to 'long' but not if INDEX is 'short':

#include <stdlib.h>

unsigned char *t_run_test(unsigned char *in, int N)
{
  unsigned char *out = malloc (N);

  for (unsigned INDEX i = 1; i < (N - 1); i++)
    out[i] = ((3 * in[i]) - in[i - 1] - in[i + 1]);

  return out;
}

However, the -Wunsafe-loop-optimizations doesn't give us anything useful here:

(successful case, warning printed)
$ aarch64-none-elf-gcc -O3 bmark2.c -DINDEX=long -S -Wunsafe-loop-optimizations
-fdump-tree-vect-details=stdout | grep vectorized
bmark2.c:7:3: note: === vect_mark_stmts_to_be_vectorized ===
bmark2.c:7:3: note: loop vectorized
bmark2.c:3:16: note: vectorized 1 loops in function.
bmark2.c: In function 't_run_test':
bmark2.c:3:16: warning: cannot optimize loop, the loop counter may overflow
[-Wunsafe-loop-optimizations]
 unsigned char *t_run_test(unsigned char *in, int N)

(unsuccessful case, no warning)
$ aarch64-none-elf-gcc -O3 bmark2.c -DINDEX=short -S
-Wunsafe-loop-optimizations -fdump-tree-vect-details=stdout | grep vectorized
bmark2.c:7:3: note: not vectorized: number of iterations cannot be computed.
bmark2.c:3:16: note: vectorized 0 loops in function.


      parent reply	other threads:[~2015-09-25 13:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07 14:45 [Bug tree-optimization/57558] New: Issue with number of iterations calculation ysrumyan at gmail dot com
2013-06-10  8:48 ` [Bug tree-optimization/57558] " rguenth at gcc dot gnu.org
2013-10-04 11:09 ` a.sinyavin at samsung dot com
2015-05-06 15:16 ` alalaw01 at gcc dot gnu.org
2015-09-25 13:49 ` alalaw01 at gcc dot gnu.org [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-57558-4-CZWL024MeR@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).