+2018-06-21 Tom de Vries <tdevries@suse.de>
+
+ PR tree-optimization/85859
+ * tree-ssa-tail-merge.c (stmt_local_def): Copy gimple_is_call
+ test with comment from bb_no_side_effects_p.
+
2018-06-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/86232
+2018-06-21 Tom de Vries <tdevries@suse.de>
+
+ PR tree-optimization/85859
+ * gcc.dg/pr85859.c: New test.
+
2018-06-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/86232
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-ftree-tail-merge -Wno-div-by-zero -O2 -fno-dce -fno-isolate-erroneous-paths-dereference -fno-tree-dce -fno-tree-vrp" } */
+
+int b, c, d, e;
+
+__attribute__ ((noinline, noclone))
+int foo (short f)
+{
+ f %= 0;
+ return f;
+}
+
+int
+main (void)
+{
+ b = (unsigned char) __builtin_parity (d);
+ e ? foo (0) : (long) &c;
+ return 0;
+}
if (gimple_vdef (stmt) != NULL_TREE
|| gimple_has_side_effects (stmt)
|| gimple_could_trap_p_1 (stmt, false, false)
- || gimple_vuse (stmt) != NULL_TREE)
+ || gimple_vuse (stmt) != NULL_TREE
+ /* Copied from tree-ssa-ifcombine.c:bb_no_side_effects_p():
+ const calls don't match any of the above, yet they could
+ still have some side-effects - they could contain
+ gimple_could_trap_p statements, like floating point
+ exceptions or integer division by zero. See PR70586.
+ FIXME: perhaps gimple_has_side_effects or gimple_could_trap_p
+ should handle this. */
+ || is_gimple_call (stmt))
return false;
def_p = SINGLE_SSA_DEF_OPERAND (stmt, SSA_OP_DEF);