public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "belagod at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation.
Date: Tue, 31 Dec 2013 16:28:00 -0000	[thread overview]
Message-ID: <bug-59651-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 59651
           Summary: Vectorizer failing to spot dependence causes incorrect
                    code generation.
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: belagod at gcc dot gnu.org

Hi,

This patch (http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01588.html) seems to
uncover a bug in the vectorizer where it fails to spot dependence. 

When test case gcc.dg/torture/pr52943.c is compiled with -O3, the vectorizer
generates:

main ()
{
  vector(2) int * vectp_a.10;
  vector(2) int * vectp_a.9;
  vector(2) int vect_cst_.8;
  unsigned int tmp.7;
  int tmp.6;
  int b_lsm.5;
  unsigned int patt_1;
  int patt_3;
  unsigned int ivtmp_4;
  int _5;
  _Bool _6;
  int _7;
  unsigned int ivtmp_8;
  int b.1_9;
  unsigned int ivtmp_10;
  int _11;
  int patt_12;
  unsigned int patt_15;
  int b.0_16;
  int b.0_30;
  unsigned int ivtmp_31;
  int b.1_33;
  unsigned int ivtmp_34;
  int b.0_37;
  unsigned int ivtmp_39;
  unsigned int ivtmp_48;

  <bb 2>:
  _5 = a[3];
  _6 = _5 > 1;
  _7 = (int) _6;
  vect_cst_.8_43 = {_7, _7};
  vectp_a.10_44 = &MEM[(void *)&a + 8B];

  <bb 3>:
  # b.0_16 = PHI <b.1_9(7), 3(2)>
  # ivtmp_4 = PHI <ivtmp_10(7), 3(2)>
  # vectp_a.9_45 = PHI <vectp_a.9_46(7), vectp_a.10_44(2)>
  # ivtmp_8 = PHI <ivtmp_48(7), 0(2)>
  MEM[(int *)vectp_a.9_45] = vect_cst_.8_43;
  b.1_9 = b.0_16 + -1;
  ivtmp_10 = ivtmp_4 - 1;
  vectp_a.9_46 = vectp_a.9_45 + 18446744073709551608;
  ivtmp_48 = ivtmp_8 + 1;
  if (ivtmp_48 < 1)
    goto <bb 7>;
  else
    goto <bb 6>;

  <bb 4>:
  # b.0_30 = PHI <b.1_33(5), 1(6)>
  # ivtmp_31 = PHI <ivtmp_34(5), 1(6)>
  a[b.0_30] = _7;
  b.1_33 = b.0_30 + -1;
  ivtmp_34 = ivtmp_31 - 1;
  if (ivtmp_34 != 0)
    goto <bb 5>;
  else
    goto <bb 8>;

  <bb 5>:
  goto <bb 4>;

  <bb 6>:
  # b.0_37 = PHI <b.1_9(3)>
  # ivtmp_39 = PHI <ivtmp_10(3)>
  goto <bb 4>;

  <bb 7>:
  goto <bb 3>;

  <bb 8>:
  b = 0;
  _11 = a[1];
  if (_11 != 0)
    goto <bb 9>;
  else
    goto <bb 10>;

  <bb 9>:
  abort ();

  <bb 10>:
  return 0;

}


>From the above test, it seems that _7 is precalculated in BB 2 using

 _5 = a[3];
  _6 = _5 > 1;
  _7 = (int) _6;
  vect_cst_.8_43 = {_7, _7};

and stored everywhere without considering the dependence on a[3].

  MEM[(int *)vectp_a.9_45] = vect_cst_.8_43;
  ...
  # b.0_30 = PHI <b.1_33(5), 1(6)>
  # ivtmp_31 = PHI <ivtmp_34(5), 1(6)>
  a[b.0_30] = _7;
  b.1_33 = b.0_30 + -1;
  ivtmp_34 = ivtmp_31 - 1;

I observed this while running regressions on aarch64. My config is:

.../gcc/configure --target=aarch64-none-elf --prefix=.../install
--with-gmp=.../host-tools --with-mpfr=.../host-tools --with-mpc=.../host-tools
--with-pkgversion=unknown --disable-shared --disable-nls --disable-threads
--disable-tls --enable-checking=yes --enable-languages=c,c++ --with-newlib


             reply	other threads:[~2013-12-31 16:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-31 16:28 belagod at gcc dot gnu.org [this message]
2013-12-31 16:53 ` [Bug tree-optimization/59651] " bmei at broadcom dot com
2013-12-31 17:12 ` belagod at gcc dot gnu.org
2013-12-31 21:07 ` [Bug tree-optimization/59651] [4.9 Regression] " pinskia at gcc dot gnu.org
2013-12-31 22:42 ` bmei at broadcom dot com
2014-01-01 18:31 ` belagod at gcc dot gnu.org
2014-01-02 11:04 ` bmei at broadcom dot com
2014-01-02 11:37 ` belagod at gcc dot gnu.org
2014-01-03 10:53 ` belagod at gcc dot gnu.org
2014-01-03 15:41 ` meibf at gcc dot gnu.org
2014-01-04 12:04 ` jakub at gcc dot gnu.org
2014-01-21 14:16 ` mshawcroft 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-59651-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).