diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-04-13 21:39:11 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-04-13 21:39:11 +0200 |
commit | 9b91582429ca0b78f235e3c11b809a861b3d0f19 (patch) | |
tree | e69206619ac279de2033eb72eecaa2dea9038667 /gcc | |
parent | 272277dc55c3dbe52da902101046e9ccc2777710 (diff) | |
download | gcc-9b91582429ca0b78f235e3c11b809a861b3d0f19.zip gcc-9b91582429ca0b78f235e3c11b809a861b3d0f19.tar.gz gcc-9b91582429ca0b78f235e3c11b809a861b3d0f19.tar.bz2 |
re PR rtl-optimization/85376 (wrong code with -Og -fno-dce -fgcse -fno-tree-ccp -fno-tree-copy-prop)
PR rtl-optimization/85376
* simplify-rtx.c (simplify_const_unary_operation): For CLZ and CTZ and
zero op0, if C?Z_DEFINED_VALUE_AT_ZERO is false, return NULL_RTX
instead of a specific value.
* gcc.dg/pr85376.c: New test.
From-SVN: r259377
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr85376.c | 32 |
4 files changed, 46 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d28ab17..2754c48 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-04-13 Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/85376 + * simplify-rtx.c (simplify_const_unary_operation): For CLZ and CTZ and + zero op0, if C?Z_DEFINED_VALUE_AT_ZERO is false, return NULL_RTX + instead of a specific value. + 2018-04-13 Jan Hubicka <hubicka@ucw.cz> Bin Cheng <bin.cheng@arm.com> diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 23244a1..9ce180d 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1877,7 +1877,7 @@ simplify_const_unary_operation (enum rtx_code code, machine_mode mode, if (wi::ne_p (op0, 0)) int_value = wi::clz (op0); else if (! CLZ_DEFINED_VALUE_AT_ZERO (imode, int_value)) - int_value = GET_MODE_PRECISION (imode); + return NULL_RTX; result = wi::shwi (int_value, result_mode); break; @@ -1889,7 +1889,7 @@ simplify_const_unary_operation (enum rtx_code code, machine_mode mode, if (wi::ne_p (op0, 0)) int_value = wi::ctz (op0); else if (! CTZ_DEFINED_VALUE_AT_ZERO (imode, int_value)) - int_value = GET_MODE_PRECISION (imode); + return NULL_RTX; result = wi::shwi (int_value, result_mode); break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 29ac9f8..90ffbf8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-04-13 Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/85376 + * gcc.dg/pr85376.c: New test. + 2018-04-13 Andrey Belevantsev <abel@ispras.ru> PR rtl-optimization/83852 diff --git a/gcc/testsuite/gcc.dg/pr85376.c b/gcc/testsuite/gcc.dg/pr85376.c new file mode 100644 index 0000000..ede44dd --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr85376.c @@ -0,0 +1,32 @@ +/* PR rtl-optimization/85376 */ +/* { dg-do run { target int128 } } */ +/* { dg-options "-Og -fno-dce -fgcse -fno-tree-ccp -fno-tree-copy-prop -Wno-psabi" } */ + +typedef unsigned int U __attribute__ ((vector_size (64))); +typedef unsigned __int128 V __attribute__ ((vector_size (64))); +unsigned int e, i, l; +unsigned char f; +U g, h, k, j; + +static inline V +foo (unsigned char n, unsigned short o, unsigned int p, U q, U r, U s) +{ + unsigned int t; + o <<= 5; + q[7] >>= __builtin_add_overflow (0xfffffff0, __builtin_ffs (n), &s[5]); + t = __builtin_ffs (g[7]); + e *= __builtin_sub_overflow (o, t, &f); + return f + (V) g + (V) h + (V) q + i + (V) j + (V) s + (V) k + l; +} + +int +main () +{ + if (__SIZEOF_INT128__ != 16 || __SIZEOF_INT__ != 4 || __CHAR_BIT__ != 8) + return 0; + V x = foo (0, 1, 5, (U) { }, (U) { }, (U) { }); + for (unsigned i = 0; i < 4; i++) + if ((unsigned int) x[i] != 0x20) + __builtin_abort (); + return 0; +} |