public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation.
@ 2013-12-31 16:28 belagod at gcc dot gnu.org
  2013-12-31 16:53 ` [Bug tree-optimization/59651] " bmei at broadcom dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: belagod at gcc dot gnu.org @ 2013-12-31 16:28 UTC (permalink / raw)
  To: gcc-bugs

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


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

end of thread, other threads:[~2014-01-21 14:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-31 16:28 [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation belagod at gcc dot gnu.org
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

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).