On Tue, Sep 15, 2020 at 10:49:46AM +0930, Alan Modra wrote: > Implement more two insn constants.
And tests. rot_cst1 checks the values generated, rot_cst2 checks instruction count. * gcc.target/powerpc/rot_cst.h, * gcc.target/powerpc/rot_cst1.c, * gcc.target/powerpc/rot_cst2.c: New tests. diff --git a/gcc/testsuite/gcc.target/powerpc/rot_cst.h b/gcc/testsuite/gcc.target/powerpc/rot_cst.h new file mode 100644 index 00000000000..0d100d61233 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/rot_cst.h @@ -0,0 +1,269 @@ +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c1 (void) +{ + return 0xc000000000000000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c2 (void) +{ + return 0xc00000000000000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c3 (void) +{ + return 0xc0000000000000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c4 (void) +{ + return 0xc000000000000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c5 (void) +{ + return 0xc00000000000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c6 (void) +{ + return 0xc0000000000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c7 (void) +{ + return 0xc000000000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c8 (void) +{ + return 0xc00000000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c9 (void) +{ + return 0xc0000000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c10 (void) +{ + return 0xc000000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c11 (void) +{ + return 0xc00000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c12 (void) +{ + return 0xc0000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c13 (void) +{ + return 0xc000ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c14 (void) +{ + return 0xc00ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c15 (void) +{ + return 0xc0ULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +c16 (void) +{ + return 0xcULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b1 (void) +{ + return 0xbfffffffffffffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b2 (void) +{ + return 0xbffffffffffffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b3 (void) +{ + return 0xbfffffffffffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b4 (void) +{ + return 0xbffffffffffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b5 (void) +{ + return 0xbfffffffffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b6 (void) +{ + return 0xbffffffffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b7 (void) +{ + return 0xbfffffffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b8 (void) +{ + return 0xbffffffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b9 (void) +{ + return 0xbfffffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b10 (void) +{ + return 0xbffffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b11 (void) +{ + return 0xbfffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b12 (void) +{ + return 0xbffffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b13 (void) +{ + return 0xbfffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b14 (void) +{ + return 0xbffULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b15 (void) +{ + return 0xbfULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +b16 (void) +{ + return 0xbULL; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r1 (void) +{ + return -0x124ULL << 48; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r2 (void) +{ + return -0x124ULL << 44; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r3 (void) +{ + return -0x124ULL << 40; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r4 (void) +{ + return -0x124ULL << 32; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r5 (void) +{ + return -0x124ULL << 28; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r6 (void) +{ + return -0x124ULL << 24; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r7 (void) +{ + return -0x124ULL << 20; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r8 (void) +{ + return -0x124ULL << 16; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r9 (void) +{ + return -0x124ULL << 12; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r10 (void) +{ + return -0x124ULL << 8; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r11 (void) +{ + return -0x124ULL << 4; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +r12 (void) +{ + return -0x124ULL << 0; +} + +unsigned long long __attribute__ ((__noinline__, __noclone__)) +lis1 (void) +{ + return 0x89ab0000ffffULL; +} diff --git a/gcc/testsuite/gcc.target/powerpc/rot_cst1.c b/gcc/testsuite/gcc.target/powerpc/rot_cst1.c new file mode 100644 index 00000000000..30219dd1438 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/rot_cst1.c @@ -0,0 +1,68 @@ +/* { dg-do run { target lp64 } } */ +/* { dg-options "-O2" } */ + +#include "rot_cst.h" + +struct fun { + unsigned long long (*f) (void); + unsigned long long val; +}; + +volatile struct fun values[] = { + { c1, 0xc000000000000000ULL }, + { c2, 0xc00000000000000ULL }, + { c3, 0xc0000000000000ULL }, + { c4, 0xc000000000000ULL }, + { c5, 0xc00000000000ULL }, + { c6, 0xc0000000000ULL }, + { c7, 0xc000000000ULL }, + { c8, 0xc00000000ULL }, + { c9, 0xc0000000ULL }, + { c10, 0xc000000ULL }, + { c11, 0xc00000ULL }, + { c12, 0xc0000ULL }, + { c13, 0xc000ULL }, + { c14, 0xc00ULL }, + { c15, 0xc0ULL }, + { c16, 0xcULL }, + { b1, 0xbfffffffffffffffULL }, + { b2, 0xbffffffffffffffULL }, + { b3, 0xbfffffffffffffULL }, + { b4, 0xbffffffffffffULL }, + { b5, 0xbfffffffffffULL }, + { b6, 0xbffffffffffULL }, + { b7, 0xbfffffffffULL }, + { b8, 0xbffffffffULL }, + { b9, 0xbfffffffULL }, + { b10, 0xbffffffULL }, + { b11, 0xbfffffULL }, + { b12, 0xbffffULL }, + { b13, 0xbfffULL }, + { b14, 0xbffULL }, + { b15, 0xbfULL }, + { b16, 0xbULL }, + { r1, -0x124ULL << 48 }, + { r2, -0x124ULL << 44 }, + { r3, -0x124ULL << 40 }, + { r4, -0x124ULL << 32 }, + { r5, -0x124ULL << 28 }, + { r6, -0x124ULL << 24 }, + { r7, -0x124ULL << 20 }, + { r8, -0x124ULL << 16 }, + { r9, -0x124ULL << 12 }, + { r10, -0x124ULL << 8 }, + { r11, -0x124ULL << 4 }, + { r12, -0x124ULL << 0 }, + { lis1, 0x89ab0000ffffULL } +}; + +int +main (void) +{ + volatile struct fun *t; + + for (t = values; t < values + sizeof (values) / sizeof (values[0]); ++t) + if (t->f () != t->val) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/rot_cst2.c b/gcc/testsuite/gcc.target/powerpc/rot_cst2.c new file mode 100644 index 00000000000..d5d45ead043 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/rot_cst2.c @@ -0,0 +1,6 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-O2" } */ + +#include "rot_cst.h" + +/* { dg-final { scan-assembler-times {(?n)^\s+[a-z]} 122 } } */ -- Alan Modra Australia Development Lab, IBM