public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "a5970694 at nepwk dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/50599] New: -ftree-vectorize generating incorrect code
Date: Mon, 03 Oct 2011 14:50:00 -0000	[thread overview]
Message-ID: <bug-50599-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             Bug #: 50599
           Summary: -ftree-vectorize generating incorrect code
    Classification: Unclassified
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: a5970694@nepwk.com


MinGW x86 4.5.2
A loop:
while(total_out < decompressed_size)
        {
            printf("%X\n",p);
            int chunk_size = *(int*)p;
            if(chunk_size > 0)
            {            
                int ret = params->decompressor(p+sizeof(int), chunk_size,
params->out+total_out, std::min(params->osize-total_out,params->bsize),
params->other);

                int real_out = (ret / params->ssize) * params->ssize;
                if(real_out != ret)
                    real_out += params->ssize;
                if(total_out + real_out >= params->isize)
                    total_out += ret;
                else
                    total_out += real_out;
                p += chunk_size+sizeof(int);

            }
            else
            {
                if(params->verify)
                {
                    memcpy(params->out+total_out, p+sizeof(int), -chunk_size);
                    p += -chunk_size;
                }
                total_out += -chunk_size;
                p += sizeof(int);
            }
        }
Compiled with -O3 -fno-strict-aliasing works funny - the printf is called twice
with the same address. And on some data I'm getting crashes in
params->decompressor, which is a 3rd party code.
I added other printfs and I see that when running the loop for the 1st time,
the code enters the 1st branch, goes to p += chunk_size+sizeof(int), increases,
goes out of the if and iterates the loop again with unchanged p.

Adding -fno-tree-vectorize solves the problem.


             reply	other threads:[~2011-10-03 14:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03 14:50 a5970694 at nepwk dot com [this message]
2011-10-04 11:05 ` [Bug tree-optimization/50599] " rguenth at gcc dot gnu.org
2015-10-20  9:25 ` mpolacek at gcc dot gnu.org

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-50599-4@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).