This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Tests for unrolling/peeling/unswitching


Hello,

here are the tests requiered by Coding conventions.

Zdenek

Attachment: diff_unroll_test.diff
Description: Text document

/* Check unrolling of loop iterating constant times.  */

/* { dg-do compile } */
/* { dg-options "-O2 -funroll-loops --param max-unrolled-insns=300 --param max-average-unrolled-insns=300 --param max-unroll-times=4" } */
/* { dg-final { scan-assembler-times "unrollconst" 6 } } */

int foo (void);

void
bla ()
{
  int i;

  for (i = 0; i < 102; i++)
    asm("unrollconst");
}
/* Check loop unrolling with preconditioning.  */

/* { dg-do compile } */
/* { dg-options "-O2 -funroll-loops --param max-unrolled-insns=300 --param max-average-unrolled-insns=300 --param max-unroll-times=4" } */
/* { dg-final { scan-assembler-times "unrollprec" 8 } } */

int foo (void);

void
bla ()
{
  int i, n = foo ();

  for (i = 0; i < n; i++)
    asm("unrollprec");
}
/* Check simple loop unrolling.  */

/* { dg-do compile } */
/* { dg-options "-O2 -funroll-all-loops --param max-unrolled-insns=300 --param max-average-unrolled-insns=300 --param max-unroll-times=4" } */
/* { dg-final { scan-assembler-times "unrollsimple" 4 } } */

int foo (void);

void
bla ()
{
  while (foo ())
    asm("unrollsimple");
}
/* Check loop peeling.  */

/* { dg-do compile } */
/* { dg-options "-O2 -fpeel-loops --param max-completely-peeled-insns=300 --param max-completely-peel-times=10" } */
/* { dg-final { scan-assembler-times "peelbody" 4 } } */

int foo (void);

void
bla ()
{
  int i;

  for (i = 0; i < 4; i++)
    asm("peelbody");
}
/* Check loop unswitching.  */

/* { dg-do compile } */
/* { dg-options "-O2 -funswitch-loops --param max-unswitch-insns=300" } */
/* { dg-final { scan-assembler-times "unswbrancha" 1 } } */
/* { dg-final { scan-assembler-times "unswbranchb" 1 } } */
/* { dg-final { scan-assembler-times "unswbranchc" 1 } } */
/* { dg-final { scan-assembler-times "unswsomecode" 2 } } */

int foo (void);

void
bla ()
{
  int branch = foo ();

  /* Unswitching.  */
  while (foo ())
    {
      if (branch)
	asm("unswbrancha");
      else
	asm("unswbranchb");
      if (foo ())
	asm("unswsomecode");
      if (branch)
	asm("unswbranchc");
    }
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]