diff options
author | Richard Biener <rguenther@suse.de> | 2016-03-30 14:18:28 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-03-30 14:18:28 +0000 |
commit | f6d2d066c26ebf0def0bd6d4be32c1d4801039fa (patch) | |
tree | b36b0ec6b50a1c3463f09015a9d7ea050802b07b | |
parent | d43242b9b980b8007a466fe894b6249d3c90aeff (diff) | |
download | gcc-f6d2d066c26ebf0def0bd6d4be32c1d4801039fa.zip gcc-f6d2d066c26ebf0def0bd6d4be32c1d4801039fa.tar.gz gcc-f6d2d066c26ebf0def0bd6d4be32c1d4801039fa.tar.bz2 |
re PR target/70450 (Wrong code with -O0 and -O1.)
2016-03-30 Richard Biener <rguenther@suse.de>
PR middle-end/70450
* fold-const.c (extract_muldiv_1): Fix thinko in wide_int::from
usage.
* gcc.dg/torture/pr70450.c: New testcase.
From-SVN: r234571
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr70450.c | 19 |
4 files changed, 34 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index db870ff..35af4ec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-03-30 Richard Biener <rguenther@suse.de> + + PR middle-end/70450 + * fold-const.c (extract_muldiv_1): Fix thinko in wide_int::from + usage. + 2016-03-30 Jakub Jelinek <jakub@redhat.com> PR target/70421 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 44fe2a2..788ecc3 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -6375,8 +6375,10 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type, bool overflow_mul_p; signop sign = TYPE_SIGN (ctype); unsigned prec = TYPE_PRECISION (ctype); - wide_int mul = wi::mul (wide_int::from (op1, prec, sign), - wide_int::from (c, prec, sign), + wide_int mul = wi::mul (wide_int::from (op1, prec, + TYPE_SIGN (TREE_TYPE (op1))), + wide_int::from (c, prec, + TYPE_SIGN (TREE_TYPE (c))), sign, &overflow_mul_p); overflow_p = TREE_OVERFLOW (c) | TREE_OVERFLOW (op1); if (overflow_mul_p diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b2dfebf..658e6c5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-03-30 Richard Biener <rguenther@suse.de> + + PR middle-end/70450 + * gcc.dg/torture/pr70450.c: New testcase. + 2016-03-30 Jakub Jelinek <jakub@redhat.com> PR target/70421 diff --git a/gcc/testsuite/gcc.dg/torture/pr70450.c b/gcc/testsuite/gcc.dg/torture/pr70450.c new file mode 100644 index 0000000..ee5e24d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr70450.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-require-effective-target lp64 } */ + +unsigned long int a = 2UL; +int b = 2; +unsigned long int c = 2UL; + +void foo () +{ + c = 2 * ((2 * a) * (2 * (-b))); +} + +int main () +{ + foo(); + if (c != 18446744073709551584UL) + __builtin_abort(); + return 0; +} |