+2017-04-25 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/79201
+ * gcc.dg/tree-ssa/ssa-sink-16.c: New testcase.
+ * gcc.target/i386/pr22152.c: Disable sinking.
+
2017-04-25 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
PR target/80464
--- /dev/null
+/* { dg-do compile } */
+/* Note PRE rotates the loop and blocks the sinking opportunity. */
+/* { dg-options "-O2 -fno-tree-pre -fdump-tree-sink -fdump-tree-optimized" } */
+
+int f(int n)
+{
+ int i,j=0;
+ for (i = 0; i < 31; i++)
+ j = __builtin_ffs(i);
+ return j;
+}
+
+/* { dg-final { scan-tree-dump "Sinking j_. = __builtin_ffs" "sink" } } */
+/* { dg-final { scan-tree-dump "return 2;" "optimized" } } */
*zero_uses_p = false;
- /* We only can sink assignments. */
- if (!is_gimple_assign (stmt))
+ /* We only can sink assignments and non-looping const/pure calls. */
+ int cf;
+ if (!is_gimple_assign (stmt)
+ && (!is_gimple_call (stmt)
+ || !((cf = gimple_call_flags (stmt)) & (ECF_CONST|ECF_PURE))
+ || (cf & ECF_LOOPING_CONST_OR_PURE)))
return false;
/* We only can sink stmts with a single definition. */
if (stmt_ends_bb_p (stmt)
|| gimple_has_side_effects (stmt)
|| (cfun->has_local_explicit_reg_vars
- && TYPE_MODE (TREE_TYPE (gimple_assign_lhs (stmt))) == BLKmode))
+ && TYPE_MODE (TREE_TYPE (gimple_get_lhs (stmt))) == BLKmode))
return false;
/* Return if there are no immediate uses of this stmt. */
/* A killing definition is not a use. */
if ((gimple_has_lhs (use_stmt)
- && operand_equal_p (gimple_assign_lhs (stmt),
+ && operand_equal_p (gimple_get_lhs (stmt),
gimple_get_lhs (use_stmt), 0))
- || stmt_kills_ref_p (use_stmt, gimple_assign_lhs (stmt)))
+ || stmt_kills_ref_p (use_stmt, gimple_get_lhs (stmt)))
{
/* If use_stmt is or might be a nop assignment then USE_STMT
acts as a use as well as definition. */
if (stmt != use_stmt
&& ref_maybe_used_by_stmt_p (use_stmt,
- gimple_assign_lhs (stmt)))
+ gimple_get_lhs (stmt)))
return false;
continue;
}