--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O -ffinite-math-only -fdump-tree-optimized" } */
+
+float foo(float x, float y, float z)
+{
+ float a = __builtin_fmaf (x, y, z);
+ float b = __builtin_fmaf (x, y, z);
+ return a - b;
+}
+
+/* { dg-final { scan-tree-dump "return 0" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
return set_ssa_val_to (lhs, rhs);
}
-/* Visit a unary operator RHS, value number it, and return true if the
+/* Visit a nary operator RHS, value number it, and return true if the
value number of LHS has changed as a result. */
static bool
-visit_unary_op (tree lhs, gimple stmt)
+visit_nary_op (tree lhs, gimple stmt)
{
bool changed = false;
tree result = vn_nary_op_lookup_stmt (stmt, NULL);
if (result)
- {
- changed = set_ssa_val_to (lhs, result);
- }
- else
- {
- changed = set_ssa_val_to (lhs, lhs);
- vn_nary_op_insert_stmt (stmt, lhs);
- }
-
- return changed;
-}
-
-/* Visit a binary operator RHS, value number it, and return true if the
- value number of LHS has changed as a result. */
-
-static bool
-visit_binary_op (tree lhs, gimple stmt)
-{
- bool changed = false;
- tree result = vn_nary_op_lookup_stmt (stmt, NULL);
-
- if (result)
- {
- changed = set_ssa_val_to (lhs, result);
- }
+ changed = set_ssa_val_to (lhs, result);
else
{
changed = set_ssa_val_to (lhs, lhs);
switch (get_gimple_rhs_class (gimple_assign_rhs_code (stmt)))
{
case GIMPLE_UNARY_RHS:
- changed = visit_unary_op (lhs, stmt);
- break;
case GIMPLE_BINARY_RHS:
- changed = visit_binary_op (lhs, stmt);
+ case GIMPLE_TERNARY_RHS:
+ changed = visit_nary_op (lhs, stmt);
break;
case GIMPLE_SINGLE_RHS:
switch (TREE_CODE_CLASS (gimple_assign_rhs_code (stmt)))
/* VOP-less references can go through unary case. */
if ((gimple_assign_rhs_code (stmt) == REALPART_EXPR
|| gimple_assign_rhs_code (stmt) == IMAGPART_EXPR
- || gimple_assign_rhs_code (stmt) == VIEW_CONVERT_EXPR )
+ || gimple_assign_rhs_code (stmt) == VIEW_CONVERT_EXPR)
&& TREE_CODE (TREE_OPERAND (gimple_assign_rhs1 (stmt), 0)) == SSA_NAME)
{
- changed = visit_unary_op (lhs, stmt);
+ changed = visit_nary_op (lhs, stmt);
break;
}
/* Fallthrough. */
case tcc_expression:
if (gimple_assign_rhs_code (stmt) == ADDR_EXPR)
{
- changed = visit_unary_op (lhs, stmt);
+ changed = visit_nary_op (lhs, stmt);
break;
}
/* Fallthrough. */