* tree-ssa-reassoc.c (zero_one_operation): When looking at rhs2,
check that it has only a single use.
* gcc.dg/tree-ssa/reassoc-26.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196520
138bc75d-0d04-0410-961f-
82ee72b054a4
+2013-03-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/56559
+ * tree-ssa-reassoc.c (zero_one_operation): When looking at rhs2,
+ check that it has only a single use.
+
2013-03-07 Richard Biener <rguenther@suse.de>
* doc/invoke.texi (fwhole-program): Discourage use in combination
+2013-03-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/56559
+ * gcc.dg/tree-ssa/reassoc-26.c: New test.
+
2013-03-07 Andreas Schwab <schwab@suse.de>
* gcc.dg/pr31490.c: Fix last change.
--- /dev/null
+/* PR tree-optimization/56559 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math" } */
+
+double a, b, c, d, e;
+
+void
+foo ()
+{
+ a = e * e;
+ b = d * e + c * e * a;
+}
the operand might be hiding in the rightmost one. */
if (opcode == MULT_EXPR
&& gimple_assign_rhs_code (stmt) == opcode
- && TREE_CODE (gimple_assign_rhs2 (stmt)) == SSA_NAME)
+ && TREE_CODE (gimple_assign_rhs2 (stmt)) == SSA_NAME
+ && has_single_use (gimple_assign_rhs2 (stmt)))
{
gimple stmt2 = SSA_NAME_DEF_STMT (gimple_assign_rhs2 (stmt));
if (stmt_is_power_of_op (stmt2, op))