On Sat, 20 Aug 2016, Uros Bizjak wrote:

> > Turning it into a compile test that counts the number of jumps threaded
> > seems potentially flaky but I'm not against it.  And I'm not sure how to
> > reliably turn it into an execution test.  Would the directives
> >
> > /* { dg-do run }  */
> > /* { dg-require-effective-target avx2 }  */
> > /* { dg-require-effective-target ia32 }  */
> > /* { dg-options "-O3 -mavx2" }  */
> >
> > work?
> 
> No, this only checks that the target is able to compile the testcase.
> In gcc.target/i386, there is ialready present nfrastructure that
> handles runtime checks (avx2_test) in your case. You can see many
> examples there.
> 
> Uros.
> 

I see, thank you.  Here's a version of the test case that should fail without
the patch and pass with the patch.  I can't test it myself because I don't have
access to a machine with AVX2.  But I can confirm that with the patch the two
bogus jump threads through the vector conditionals that were incorrectly folded
are no longered registered.

/* { dg-do run }  */
/* { dg-require-effective-target avx2 }  */
/* { dg-require-effective-target ia32 }  */
/* { dg-options "-O3 -mavx2" }  */

#include "avx2-check.h"

typedef unsigned int ui;
ui x[32*32];
ui y[32];
ui z[32];
void __attribute__ ((noinline, noclone)) foo (ui n, ui z)
{
  ui i, b;
  ui v;
 for (i = 0; i< n; i++)
  {
    v = y[i];
    if (v) {
      for (b = 0; b < 32; b++)
        if ((v >> b) & 1)
          x[i*32 +b] = z;
      y[i] = 0;
    }
  }
}

static void
avx2_test (void)
{
  int i;
  unsigned int val;
  for (i = 0; i<32; i++)
    {
      val = 1U << i;
      y[i] = (i & 1)? 0 : val;
      z[i] = i;
    }
  foo (32, 10);
  for (i=0; i<1024; i+=66)
    if (x[i] != 10)
      __builtin_abort ();
}

Reply via email to