diff mbox

Fix PR64295

Message ID alpine.LSU.2.11.1412151352510.25296@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Dec. 15, 2014, 12:53 p.m. UTC
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.
diff mbox

Patch

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;
+}