blob: ba5c82cd55c582c96a18ad417a3041e43d843613 [file] [log] [blame]
/* Check that GCC generates Armv8.1-M low over head loop instructions
for some simple loops. */
/* { dg-do run } */
/* { dg-require-effective-target arm_v8_1_lob_ok } */
/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */
/* { dg-options "-march=armv8.1-m.main -mthumb -O3 --save-temps" } */
#include <stdlib.h>
#include "lob.h"
int a[N];
int b[N];
int c[N];
int
foo (int a, int b)
{
return a + b;
}
void __attribute__((noinline))
loop1 (int *a, int *b, int *c)
{
for (int i = 0; i < N; i++)
{
a[i] = i;
b[i] = i * 2;
c[i] = a[i] + b[i];
}
}
void __attribute__((noinline))
loop2 (int *a, int *b, int *c)
{
int i = 0;
while (i < N)
{
a[i] = i - 2;
b[i] = i * 5;
c[i] = a[i] + b[i];
i++;
}
}
void __attribute__((noinline))
loop3 (int *a, int *b, int *c)
{
int i = 0;
do
{
a[i] = i - 4;
b[i] = i * 3;
c[i] = a[i] + b[i];
i++;
} while (i < N);
}
void
check (int *a, int *b, int *c)
{
for (int i = 0; i < N; i++)
{
NO_LOB;
if (c[i] != a[i] + b[i])
abort ();
}
}
int
main (void)
{
reset_data (a, b, c);
loop1 (a, b ,c);
check (a, b ,c);
reset_data (a, b, c);
loop2 (a, b ,c);
check (a, b ,c);
reset_data (a, b, c);
loop3 (a, b ,c);
check (a, b ,c);
return 0;
}
/* { dg-final { scan-assembler-times {dls\s\S*,\s\S*} 3 } } */
/* { dg-final { scan-assembler-times {le\slr,\s\S*} 3 } } */