summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2017-07-17 10:20:41 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2017-07-17 10:20:41 +0000
commit63d693d7bb9ec3cd758a135f0beea1d33d296c9e (patch)
tree73a891c66a84cfec47ab39ca54251651bb4b593c
parente7f1908e1f75cef12efb4c0a09307f0383ceacc8 (diff)
downloadgcc-63d693d7bb9ec3cd758a135f0beea1d33d296c9e.tar.gz
PR tree-optimization/81428
* match.pd (X / X -> one): Don't optimize _Fract divisions, as 1 can't be built for those types. * gcc.dg/fixed-point/pr81428.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250265 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/match.pd5
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/fixed-point/pr81428.c9
4 files changed, 21 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index db3540155ef..0c279095cf4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-07-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/81428
+ * match.pd (X / X -> one): Don't optimize _Fract divisions, as 1
+ can't be built for those types.
+
2017-07-17 Georg-Johann Lay <avr@gjlay.de>
Remove stuff dead since r239246.
diff --git a/gcc/match.pd b/gcc/match.pd
index 4c64b21b463..979085aba5a 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -243,8 +243,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* X / X is one. */
(simplify
(div @0 @0)
- /* But not for 0 / 0 so that we can get the proper warnings and errors. */
- (if (!integer_zerop (@0))
+ /* But not for 0 / 0 so that we can get the proper warnings and errors.
+ And not for _Fract types where we can't build 1. */
+ (if (!integer_zerop (@0) && !ALL_FRACT_MODE_P (TYPE_MODE (type)))
{ build_one_cst (type); }))
/* X / abs (X) is X < 0 ? -1 : 1. */
(simplify
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 141d035cf6d..4924b481427 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2017-07-17 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/81428
+ * gcc.dg/fixed-point/pr81428.c: New test.
+
PR tree-optimization/81365
* g++.dg/torture/pr81365.C: New test.
diff --git a/gcc/testsuite/gcc.dg/fixed-point/pr81428.c b/gcc/testsuite/gcc.dg/fixed-point/pr81428.c
new file mode 100644
index 00000000000..98f4b235718
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fixed-point/pr81428.c
@@ -0,0 +1,9 @@
+/* PR tree-optimization/81428 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void
+foo (long _Fract *a, long _Fract *b)
+{
+ *b = *a / *a;
+}