From 7573521f46427d36a203f72794af7188ce04de88 Mon Sep 17 00:00:00 2001 From: Hans-Peter Nilsson Date: Mon, 10 Feb 2020 17:39:00 +0100 Subject: [PATCH] gcc.target/cris/pr93372-3.c, -4.c...-35.c: New tests. PR target/93372 * gcc.target/cris/pr93372-3.c, gcc.target/cris/pr93372-4.c, gcc.target/cris/pr93372-6.c, gcc.target/cris/pr93372-7.c, gcc.target/cris/pr93372-9.c, gcc.target/cris/pr93372-10.c, gcc.target/cris/pr93372-11.c, gcc.target/cris/pr93372-12.c, gcc.target/cris/pr93372-13.c, gcc.target/cris/pr93372-14.c, gcc.target/cris/pr93372-15.c, gcc.target/cris/pr93372-16.c, gcc.target/cris/pr93372-17.c, gcc.target/cris/pr93372-18.c, gcc.target/cris/pr93372-19.c, gcc.target/cris/pr93372-20.c, gcc.target/cris/pr93372-21.c, gcc.target/cris/pr93372-22.c, gcc.target/cris/pr93372-23.c, gcc.target/cris/pr93372-24.c, gcc.target/cris/pr93372-25.c, gcc.target/cris/pr93372-26.c, gcc.target/cris/pr93372-27.c, gcc.target/cris/pr93372-28.c, gcc.target/cris/pr93372-29.c, gcc.target/cris/pr93372-30.c, gcc.target/cris/pr93372-31.c, gcc.target/cris/pr93372-32.c, gcc.target/cris/pr93372-33.c, gcc.target/cris/pr93372-34.c, gcc.target/cris/pr93372-35.c: New tests. Check that somewhat-trivially eliminable compare-instructions are eliminated, for all instructions. Note that pr93372-23.c and pr93372-24.c are xfailed with cc0. --- gcc/testsuite/ChangeLog | 17 +++++ gcc/testsuite/gcc.target/cris/pr93372-10.c | 9 +++ gcc/testsuite/gcc.target/cris/pr93372-11.c | 46 ++++++++++++ gcc/testsuite/gcc.target/cris/pr93372-12.c | 7 ++ gcc/testsuite/gcc.target/cris/pr93372-13.c | 18 +++++ gcc/testsuite/gcc.target/cris/pr93372-14.c | 13 ++++ gcc/testsuite/gcc.target/cris/pr93372-15.c | 15 ++++ gcc/testsuite/gcc.target/cris/pr93372-16.c | 42 +++++++++++ gcc/testsuite/gcc.target/cris/pr93372-17.c | 7 ++ gcc/testsuite/gcc.target/cris/pr93372-18.c | 24 ++++++ gcc/testsuite/gcc.target/cris/pr93372-19.c | 8 ++ gcc/testsuite/gcc.target/cris/pr93372-20.c | 8 ++ gcc/testsuite/gcc.target/cris/pr93372-21.c | 8 ++ gcc/testsuite/gcc.target/cris/pr93372-22.c | 8 ++ gcc/testsuite/gcc.target/cris/pr93372-23.c | 21 ++++++ gcc/testsuite/gcc.target/cris/pr93372-24.c | 19 +++++ gcc/testsuite/gcc.target/cris/pr93372-25.c | 8 ++ gcc/testsuite/gcc.target/cris/pr93372-26.c | 7 ++ gcc/testsuite/gcc.target/cris/pr93372-27.c | 8 ++ gcc/testsuite/gcc.target/cris/pr93372-28.c | 8 ++ gcc/testsuite/gcc.target/cris/pr93372-29.c | 40 ++++++++++ gcc/testsuite/gcc.target/cris/pr93372-3.c | 15 ++++ gcc/testsuite/gcc.target/cris/pr93372-30.c | 31 ++++++++ gcc/testsuite/gcc.target/cris/pr93372-31.c | 33 +++++++++ gcc/testsuite/gcc.target/cris/pr93372-32.c | 10 +++ gcc/testsuite/gcc.target/cris/pr93372-33.c | 10 +++ gcc/testsuite/gcc.target/cris/pr93372-34.c | 45 ++++++++++++ gcc/testsuite/gcc.target/cris/pr93372-35.c | 49 +++++++++++++ gcc/testsuite/gcc.target/cris/pr93372-4.c | 12 +++ gcc/testsuite/gcc.target/cris/pr93372-6.c | 18 +++++ gcc/testsuite/gcc.target/cris/pr93372-7.c | 85 ++++++++++++++++++++++ gcc/testsuite/gcc.target/cris/pr93372-9.c | 9 +++ 32 files changed, 658 insertions(+) create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-10.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-11.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-12.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-13.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-14.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-15.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-16.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-17.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-18.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-19.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-20.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-21.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-22.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-23.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-24.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-25.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-26.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-27.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-28.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-29.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-3.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-30.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-31.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-32.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-33.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-34.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-35.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-4.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-6.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-7.c create mode 100644 gcc/testsuite/gcc.target/cris/pr93372-9.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2fd6aaf908..69c564ff952 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -2,9 +2,26 @@ * gcc.target/cris/cris.exp (check_effective_target_cc0): New. + PR target/93372 * gcc.target/cris/pr93372-1.c: New test. * gcc.target/cris/pr93372-2.c, gcc.target/cris/pr93372-5.c, gcc.target/cris/pr93372-8.c: New tests. + * gcc.target/cris/pr93372-3.c, gcc.target/cris/pr93372-4.c, + gcc.target/cris/pr93372-6.c, gcc.target/cris/pr93372-7.c, + gcc.target/cris/pr93372-9.c, gcc.target/cris/pr93372-10.c, + gcc.target/cris/pr93372-11.c, gcc.target/cris/pr93372-12.c, + gcc.target/cris/pr93372-13.c, gcc.target/cris/pr93372-14.c, + gcc.target/cris/pr93372-15.c, gcc.target/cris/pr93372-16.c, + gcc.target/cris/pr93372-17.c, gcc.target/cris/pr93372-18.c, + gcc.target/cris/pr93372-19.c, gcc.target/cris/pr93372-20.c, + gcc.target/cris/pr93372-21.c, gcc.target/cris/pr93372-22.c, + gcc.target/cris/pr93372-23.c, gcc.target/cris/pr93372-24.c, + gcc.target/cris/pr93372-25.c, gcc.target/cris/pr93372-26.c, + gcc.target/cris/pr93372-27.c, gcc.target/cris/pr93372-28.c, + gcc.target/cris/pr93372-29.c, gcc.target/cris/pr93372-30.c, + gcc.target/cris/pr93372-31.c, gcc.target/cris/pr93372-32.c, + gcc.target/cris/pr93372-33.c, gcc.target/cris/pr93372-34.c, + gcc.target/cris/pr93372-35.c: New tests. 2020-02-10 Jakub Jelinek diff --git a/gcc/testsuite/gcc.target/cris/pr93372-10.c b/gcc/testsuite/gcc.target/cris/pr93372-10.c new file mode 100644 index 00000000000..76e8fef8d29 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-10.c @@ -0,0 +1,9 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times "\tcmp" 1 } } */ +/* { dg-final { scan-assembler-not "\ttest" } } */ + +#define t char +#include "pr93372-3.c" +#include "pr93372-7.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-11.c b/gcc/testsuite/gcc.target/cris/pr93372-11.c new file mode 100644 index 00000000000..b5eb5ebb089 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-11.c @@ -0,0 +1,46 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#ifndef t +#define t short int +#endif +#ifndef t2 +#define t2 int +#endif + +#define eq_op(x) ((x) == 0) +#define ne_op(x) ((x) != 0) +#define gt_op(x) ((x) > 0) +#define gtu_op(x) ((x) > 0) +#define lt_op(x) ((x) < 0) +#define ltu_op(x) ((x) < 0) +#define ge_op(x) ((x) >= 0) +#define geu_op(x) ((x) >= 0) +#define le_op(x) ((x) <= 0) +#define leu_op(x) ((x) <= 0) + +#define f(n, T, T2) \ +T2 f ## n(T *a, T *b, T2 *d) \ +{ \ + T2 c = *a; \ + *d = c; \ + *b = n ## _op (c); \ + return c; \ +} + +f(eq, t, t2) +f(ne, t, t2) +f(gt, t, t2) +f(gtu, unsigned t, unsigned t2) +f(lt, t, t2) +#if 0 +f(ltu, unsigned t, unsigned t2) +#endif +f(ge, t, t2) +#if 0 +f(geu, t, t2) +#endif +f(le, t, t2) +f(leu, t, t2) diff --git a/gcc/testsuite/gcc.target/cris/pr93372-12.c b/gcc/testsuite/gcc.target/cris/pr93372-12.c new file mode 100644 index 00000000000..429e0b84946 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-12.c @@ -0,0 +1,7 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#define t char +#include "pr93372-11.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-13.c b/gcc/testsuite/gcc.target/cris/pr93372-13.c new file mode 100644 index 00000000000..ff0d0f8a12a --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-13.c @@ -0,0 +1,18 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest|\tor" } } */ + +extern void foo(void); + +void f(long long int a, long long int b) +{ + if (a + b == 0) + foo(); +} + +void g(long long int a, long long int b) +{ + if (a + b >= 0) + foo(); +} diff --git a/gcc/testsuite/gcc.target/cris/pr93372-14.c b/gcc/testsuite/gcc.target/cris/pr93372-14.c new file mode 100644 index 00000000000..e0a846ee77b --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-14.c @@ -0,0 +1,13 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times "\tcmp|\ttest" 2 } } */ + +extern void foo(void); + +void f(long long int a, long long int b) +{ + /* Trivial check that we don't eliminate a non-eliminable compare. */ + if (a + b <= 0) + foo(); +} diff --git a/gcc/testsuite/gcc.target/cris/pr93372-15.c b/gcc/testsuite/gcc.target/cris/pr93372-15.c new file mode 100644 index 00000000000..4932762af92 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-15.c @@ -0,0 +1,15 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times "\tcmp|\ttest" 1 } } */ + +int f(int a, int b, int *d) +{ + int c = a + b; + + *d = (c == 0); + + /* See also pr93372-6.c. We should get exactly one compare + instruction for this condition. */ + return c <= 0; +} diff --git a/gcc/testsuite/gcc.target/cris/pr93372-16.c b/gcc/testsuite/gcc.target/cris/pr93372-16.c new file mode 100644 index 00000000000..7e69d862c3f --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-16.c @@ -0,0 +1,42 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#ifndef t +#define t short int +#endif +#ifndef t2 +#define t2 t +#endif +#ifndef op +#define op + +#endif +#ifndef do_f +#define do_f 1 +#endif +#ifndef do_g +#define do_g 1 +#endif + +extern void foo(void); + +#if do_f +void f(t a, t b) +{ + t2 c = a op b; + + if (c == 0) + foo(); +} +#endif + +#if do_g +void g(t a, t b) +{ + t2 c = a op b; + + if (c >= 0) + foo(); +} +#endif diff --git a/gcc/testsuite/gcc.target/cris/pr93372-17.c b/gcc/testsuite/gcc.target/cris/pr93372-17.c new file mode 100644 index 00000000000..05b5c31cc45 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-17.c @@ -0,0 +1,7 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#define t signed char +#include "pr93372-16.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-18.c b/gcc/testsuite/gcc.target/cris/pr93372-18.c new file mode 100644 index 00000000000..deb45e4f6ac --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-18.c @@ -0,0 +1,24 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest|\tor" } } */ + +#ifndef t +#define t long long +#endif +#ifndef t2 +#define t2 t +#endif +#ifndef op +#define op - +#endif + +extern void foo(t2); + +void g(t a, t b) +{ + t2 c = a op b; + + if (c >= 0) + foo(c); +} diff --git a/gcc/testsuite/gcc.target/cris/pr93372-19.c b/gcc/testsuite/gcc.target/cris/pr93372-19.c new file mode 100644 index 00000000000..9a4e117d9b0 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-19.c @@ -0,0 +1,8 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#define t int +#define op - +#include "pr93372-18.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-20.c b/gcc/testsuite/gcc.target/cris/pr93372-20.c new file mode 100644 index 00000000000..12870b36807 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-20.c @@ -0,0 +1,8 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#define t short int +#define op - +#include "pr93372-18.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-21.c b/gcc/testsuite/gcc.target/cris/pr93372-21.c new file mode 100644 index 00000000000..76845cb1a6f --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-21.c @@ -0,0 +1,8 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#define t signed char +#define op - +#include "pr93372-18.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-22.c b/gcc/testsuite/gcc.target/cris/pr93372-22.c new file mode 100644 index 00000000000..23b38f6ee6b --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-22.c @@ -0,0 +1,8 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#define t int +#define op & +#include "pr93372-16.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-23.c b/gcc/testsuite/gcc.target/cris/pr93372-23.c new file mode 100644 index 00000000000..fcefc9ab918 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-23.c @@ -0,0 +1,21 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ +/* For the f2, we want an andq, not and.w. */ +/* { dg-final { scan-assembler "\tandq 20," } } */ +/* { dg-final { scan-assembler-not "\tand.w 20," } } */ +/* We don't want a move.w that sets condition codes, but it happens for + cc0, as the "andq" that is the last insn before the branch, is for an + alternative that matches -32..31 and thus marked as clobbering + condition codes. */ +/* { dg-final { scan-assembler-not "\tmove.w" { xfail cc0 } } } */ + +#define op & +#include "pr93372-16.c" + +#undef op +#define op & 20 & +#define f f2 +#define g g2 +#include "pr93372-16.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-24.c b/gcc/testsuite/gcc.target/cris/pr93372-24.c new file mode 100644 index 00000000000..87f10e93c06 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-24.c @@ -0,0 +1,19 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ +/* For the f2, we want an andq, not and.b. */ +/* { dg-final { scan-assembler "\tandq 20," } } */ +/* { dg-final { scan-assembler-not "\tand.b 20," } } */ +/* See pr93372-23.c regarding the xfail. */ +/* { dg-final { scan-assembler-not "\tmove.b" { xfail cc0 } } } */ + +#define op & +#define t signed char +#include "pr93372-16.c" + +#undef op +#define op & 20 & +#define f f2 +#define g g2 +#include "pr93372-16.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-25.c b/gcc/testsuite/gcc.target/cris/pr93372-25.c new file mode 100644 index 00000000000..448083b7570 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-25.c @@ -0,0 +1,8 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#define t int +#define op | +#include "pr93372-16.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-26.c b/gcc/testsuite/gcc.target/cris/pr93372-26.c new file mode 100644 index 00000000000..c44c918a841 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-26.c @@ -0,0 +1,7 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#define op | +#include "pr93372-16.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-27.c b/gcc/testsuite/gcc.target/cris/pr93372-27.c new file mode 100644 index 00000000000..38bfd947987 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-27.c @@ -0,0 +1,8 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#define op | +#define t signed char +#include "pr93372-16.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-28.c b/gcc/testsuite/gcc.target/cris/pr93372-28.c new file mode 100644 index 00000000000..3d32a7fa90b --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-28.c @@ -0,0 +1,8 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#define op ^ +#define t int +#include "pr93372-18.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-29.c b/gcc/testsuite/gcc.target/cris/pr93372-29.c new file mode 100644 index 00000000000..7fb0fe8fb09 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-29.c @@ -0,0 +1,40 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#ifndef t +#define t int +#endif +#ifndef t2 +#define t2 t +#endif +#ifndef op +#define op(x) ~(x) +#endif + +extern void foo(t2); + +t2 f(t a, t2 *b, t2 *d) +{ + t2 c = op(a); + + *b = c; + + if (c != 0) + *d = c; + + return c; +} + +t2 g(t a, t2 *b, t2 *d) +{ + t2 c = op(a); + + *b = c; + + if (c <= 0) + *d = c; + + return c; +} diff --git a/gcc/testsuite/gcc.target/cris/pr93372-3.c b/gcc/testsuite/gcc.target/cris/pr93372-3.c new file mode 100644 index 00000000000..c0fbdd83a33 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-3.c @@ -0,0 +1,15 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times "\tcmp" 1 } } */ + +#ifndef t +#define t int +#endif + +int ff(t a, t b, t *d) +{ + *d = (a == b); + + return a > b; +} diff --git a/gcc/testsuite/gcc.target/cris/pr93372-30.c b/gcc/testsuite/gcc.target/cris/pr93372-30.c new file mode 100644 index 00000000000..a61e8c42a9e --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-30.c @@ -0,0 +1,31 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#define t int +#define op >> +#define f ashrtf + +/* If we don't disable g, it will degenerate into a test of the + input. */ +#define do_g 0 + +#include "pr93372-16.c" +#undef do_g + +#undef t +#define t unsigned int +#undef f +#undef g +#define f lshrtf +#define g lshrtg +#include "pr93372-16.c" + +#undef f +#undef g +#undef op +#define op << +#define f shlf +#define g shlg +#include "pr93372-16.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-31.c b/gcc/testsuite/gcc.target/cris/pr93372-31.c new file mode 100644 index 00000000000..649a90aa553 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-31.c @@ -0,0 +1,33 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { "*-*-*" } { "-march=v0" } { "" } } */ +/* { dg-options "-O2" { target march_option } } */ +/* { dg-options "-O2 -march=v10" { target { ! march_option } } } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#ifndef t +#define t int +#endif +#ifndef t2 +#define t2 t +#endif +#ifndef t3 +#define t3 t +#endif +#ifndef op +#define op(xx) __builtin_clz(xx) +#endif + +extern t3 x; + +t2 f(t a, t2 *b, t2 *d) +{ + t2 c = op(a); + + *b = c; + + if (c != 0) + *d = c; + + return c; +} diff --git a/gcc/testsuite/gcc.target/cris/pr93372-32.c b/gcc/testsuite/gcc.target/cris/pr93372-32.c new file mode 100644 index 00000000000..64ab6789534 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-32.c @@ -0,0 +1,10 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { "*-*-*" } { "-march=*" } { "" } } */ +/* { dg-options "-O2 -march=v10" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ +/* { dg-final { scan-assembler "\tswapwb " } } */ + +#define op(xx) __builtin_bswap32(xx) + +#include "pr93372-31.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-33.c b/gcc/testsuite/gcc.target/cris/pr93372-33.c new file mode 100644 index 00000000000..9c7d2ba93c8 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-33.c @@ -0,0 +1,10 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ +/* { dg-final { scan-assembler "\tbound" } } */ + +#define t unsigned int +#define op(xx) ((xx) < x ? (xx) : x) + +#include "pr93372-31.c" diff --git a/gcc/testsuite/gcc.target/cris/pr93372-34.c b/gcc/testsuite/gcc.target/cris/pr93372-34.c new file mode 100644 index 00000000000..8bd3b4434ac --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-34.c @@ -0,0 +1,45 @@ +/* Check that btst/btstq other than a field starting at bit 0, is used. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tand" } } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ +/* { dg-final { scan-assembler-times "\tbtstq" 3 } } */ +/* { dg-final { scan-assembler-times "\tbtst " 3 } } */ + +void foo(void); + +void f(int *a) +{ + if ((*a & 32) != 0) + foo(); +} + +void g(short int *a) +{ + if ((*a & 128) == 0) + foo(); +} + +void h(char *a) +{ + if ((*a & 64) != 0) + foo(); +} + +void i(int *a, unsigned int n) +{ + if ((*a & (1 << n)) != 0) + foo(); +} + +void j(short int *a, unsigned int n) +{ + if ((*a & (1 << n)) == 0) + foo(); +} + +void k(char *a, unsigned int n) +{ + if ((*a & (1 << n)) != 0) + foo(); +} diff --git a/gcc/testsuite/gcc.target/cris/pr93372-35.c b/gcc/testsuite/gcc.target/cris/pr93372-35.c new file mode 100644 index 00000000000..4e364972033 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-35.c @@ -0,0 +1,49 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ +/* { dg-final { scan-assembler "\tneg" } } */ + +void foo(void); + +#ifndef op +#define op(x) -(x) +#endif + +#define f(k, T, T2) \ +void f ## k (T *a, T2 *b) \ +{ \ + T2 d = op(*a); \ + *b = d; \ + if (d != 0) \ + foo(); \ +} + +#define ff(x, y) f(x, y, y) + +/* For NEG, gcc prefers to test the source (before the operation), but + will settle for the destination. For SImode, the destination is + allocated to a different register than the source. Not that + important; just skip the "int" variant for now. */ +#ifndef do_1 +#define do_1 0 +#endif + +#ifndef do_2 +#define do_2 1 +#endif +#ifndef do_3 +#define do_3 1 +#endif + +#if do_1 +ff(1, int) +#endif + +#if do_2 +ff(2, short int) +#endif + +#if do_3 +ff(3, signed char) +#endif diff --git a/gcc/testsuite/gcc.target/cris/pr93372-4.c b/gcc/testsuite/gcc.target/cris/pr93372-4.c new file mode 100644 index 00000000000..e9faf9ff869 --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-4.c @@ -0,0 +1,12 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +int f(int a, int *b) +{ + /* As seen in powisf2, the result of a shift is checked for zeroness. */ + int c = a >> 1; + *b = (c == 0); + return c; +} diff --git a/gcc/testsuite/gcc.target/cris/pr93372-6.c b/gcc/testsuite/gcc.target/cris/pr93372-6.c new file mode 100644 index 00000000000..69ae55ccbfd --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-6.c @@ -0,0 +1,18 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ +/* { dg-final { scan-assembler "\tlsr|\tsmi" } } */ + +/* Regarding the "lsr", see pr93372-2.c; we get a shift for the + sign-bit. For "<", that's equally optimal to smi; we just want this + test to be different with the "<" instead of ">=". */ + +int f(int a, int b, int *d) +{ + int c = a + b; + + *d = (c == 0); + + return c < 0; +} diff --git a/gcc/testsuite/gcc.target/cris/pr93372-7.c b/gcc/testsuite/gcc.target/cris/pr93372-7.c new file mode 100644 index 00000000000..fb22b20d9de --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-7.c @@ -0,0 +1,85 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */ + +#ifndef t +#define t int +#endif + +t feq(t *a, t *b) +{ + t c = *a; + *b = c == 0; + return c; +} + +t fne(t *a, t *b) +{ + t c = *a; + *b = c != 0; + return c; +} + +t fgt(t *a, t *b) +{ + t c = *a; + *b = c > 0; + return c; +} + +unsigned t fgtu(unsigned t *a, unsigned t *b) +{ + unsigned t c = *a; + *b = c > 0; + return c; +} + +t flt(t *a, t *b) +{ + t c = *a; + *b = c < 0; + return c; +} + +#if 0 +/* Always false... */ +unsigned t fltu(unsigned t *a, unsigned t *b) +{ + unsigned t c = *a; + *b = c < 0; + return c; +} +#endif + +t fge(t *a, t *b) +{ + t c = *a; + *b = c >= 0; + return c; +} + +#if 0 +/* Always true... */ +unsigned t fgeu(unsigned t *a, unsigned t *b) +{ + unsigned t c = *a; + *b = c > 0; + return c; +} +#endif + +t fle(t *a, t *b) +{ + t c = *a; + *b = c <= 0; + return c; +} + +/* Same as eq... */ +unsigned t fleu(unsigned t *a, unsigned t *b) +{ + unsigned t c = *a; + *b = c <= 0; + return c; +} diff --git a/gcc/testsuite/gcc.target/cris/pr93372-9.c b/gcc/testsuite/gcc.target/cris/pr93372-9.c new file mode 100644 index 00000000000..9a11b8c063c --- /dev/null +++ b/gcc/testsuite/gcc.target/cris/pr93372-9.c @@ -0,0 +1,9 @@ +/* Check that eliminable compare-instructions are eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times "\tcmp" 1 } } */ +/* { dg-final { scan-assembler-not "\ttest" } } */ + +#define t short int +#include "pr93372-3.c" +#include "pr93372-7.c" -- 2.30.2