From: Jakub Jelinek Date: Wed, 11 Sep 2019 11:37:39 +0000 (+0200) Subject: re PR rtl-optimization/89435 (wrong code with -O1 -march=armv4 -fno-forward-propagate... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fd3bfefbd93259ca4af64e821388a6ec824fa0dd;p=gcc.git 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 --- 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; +}