This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR64295
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Dec 2014 13:53:41 +0100 (CET)
- Subject: [PATCH] Fix PR64295
- Authentication-results: sourceware.org; auth=none
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
2014-12-15 Richard Biener <rguenther@suse.de>
PR middle-end/64295
* match.pd (X / CST -> X * (1 / CST): Use const_binop instead of
fold_binary to compute the constant to multiply with.
* gcc.dg/pr64295.c: New testcase.
Index: gcc/match.pd
===================================================================
--- gcc/match.pd (revision 218668)
+++ gcc/match.pd (working copy)
@@ -186,7 +186,7 @@ (define_operator_list inverted_tcc_compa
(if (flag_reciprocal_math
&& !real_zerop (@1))
(with
- { tree tem = fold_binary (RDIV_EXPR, type, build_one_cst (type), @1); }
+ { tree tem = const_binop (RDIV_EXPR, type, build_one_cst (type), @1); }
(if (tem)
(mult @0 { tem; } ))))
(if (cst != COMPLEX_CST)
Index: gcc/testsuite/gcc.dg/pr64295.c
===================================================================
--- gcc/testsuite/gcc.dg/pr64295.c (revision 0)
+++ gcc/testsuite/gcc.dg/pr64295.c (working copy)
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O -frounding-math -funsafe-math-optimizations" } */
+
+double
+f (double g)
+{
+ return g / 3;
+}