From fd3bfefbd93259ca4af64e821388a6ec824fa0dd Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 11 Sep 2019 13:37:39 +0200 Subject: [PATCH] re PR rtl-optimization/89435 (wrong code with -O1 -march=armv4 -fno-forward-propagate with __builtin_sub_overflow()) PR rtl-optimization/89435 PR rtl-optimization/89795 PR rtl-optimization/91720 * gcc.dg/pr89435.c: New test. * gcc.dg/pr89795.c: New test. * gcc.dg/pr91720.c: New test. From-SVN: r275642 --- gcc/testsuite/ChangeLog | 9 +++++++++ gcc/testsuite/gcc.dg/pr89435.c | 21 +++++++++++++++++++++ gcc/testsuite/gcc.dg/pr89795.c | 25 +++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pr91720.c | 22 ++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr89435.c create mode 100644 gcc/testsuite/gcc.dg/pr89795.c create mode 100644 gcc/testsuite/gcc.dg/pr91720.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 940be7f8e2f..aa3127cf3fd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2019-09-11 Jakub Jelinek + + PR rtl-optimization/89435 + PR rtl-optimization/89795 + PR rtl-optimization/91720 + * gcc.dg/pr89435.c: New test. + * gcc.dg/pr89795.c: New test. + * gcc.dg/pr91720.c: New test. + 2019-09-11 Richard Biener PR tree-optimization/90387 diff --git a/gcc/testsuite/gcc.dg/pr89435.c b/gcc/testsuite/gcc.dg/pr89435.c new file mode 100644 index 00000000000..d72d087f5ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr89435.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/89435 */ +/* { dg-do run } */ +/* { dg-options "-O1 -fno-forward-propagate -fno-tree-forwprop -fno-tree-ccp" } */ + +unsigned short a; +unsigned int b, c, d, e, f; + +int +main () +{ +#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 + unsigned char g = e = __builtin_mul_overflow_p (5, 542624702, 0); + d = __builtin_bswap64 (a); + b = __builtin_sub_overflow ((unsigned char) -e, (unsigned int) d, &g); + e = __builtin_mul_overflow (b, c, &a); + f = g + e; + if (f != 0xff) + __builtin_abort (); +#endif + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr89795.c b/gcc/testsuite/gcc.dg/pr89795.c new file mode 100644 index 00000000000..4ceaa433f3c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr89795.c @@ -0,0 +1,25 @@ +/* PR rtl-optimization/89795 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-dce -fno-forward-propagate -fno-sched-pressure" } */ + +unsigned char a; +unsigned b, c, d; + +int +main () +{ +#if __CHAR_BIT__ == 8 + unsigned x; + int e, f; + unsigned char g; + e = __builtin_bswap32 (a); + f = __builtin_ffs (~(unsigned short) e); + a = __builtin_mul_overflow ((unsigned char) 0xf7, f, &g); + a |= __builtin_sub_overflow_p (c, 0, (unsigned char) 0); + d = g + b; + x = d; + if (x != 0xf7) + __builtin_abort (); +#endif + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr91720.c b/gcc/testsuite/gcc.dg/pr91720.c new file mode 100644 index 00000000000..4abdace94da --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr91720.c @@ -0,0 +1,22 @@ +/* PR rtl-optimization/91720 */ +/* { dg-do run } */ +/* { dg-options "-Og -fno-forward-propagate -frerun-cse-after-loop -fno-tree-fre" } */ + +unsigned a, b; + +int +main () +{ +#if __CHAR_BIT__ == 8 + unsigned c = 1; + unsigned long long d = 0; + unsigned char e = 0; + e = __builtin_sub_overflow (d, e, &a) ? 0 : 0x80; + e = e << 7 | e >> c; + __builtin_memmove (&d, &a, 2); + b = e; + if (b != 0x40) + __builtin_abort (); +#endif + return 0; +} -- 2.30.2