PR tree-optimization/103451
gcc/ChangeLog:
* range-op.cc (operator_div::wi_fold): Remove
can_throw_non_call_exceptions special case.
* tree-ssa-sink.c (sink_code_in_bb): Same.
gcc/testsuite/ChangeLog:
* gcc.dg/pr103451.c: New test.
return;
}
- // If flag_non_call_exceptions, we must not eliminate a division by zero.
- if (cfun->can_throw_non_call_exceptions)
- {
- r.set_varying (type);
- return;
- }
-
// If we're definitely dividing by zero, there's nothing to do.
if (wi_zero_p (type, divisor_min, divisor_max))
{
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O2 -w -fnon-call-exceptions -fno-delete-dead-exceptions -fdump-tree-optimized" }
+
+int func_10_ptr_12;
+
+void func_10(long li_8)
+{
+ long *ptr_9 = &li_8;
+ li_8 &= *ptr_9 / 0 ?: li_8;
+ for (;;)
+ func_10_ptr_12 &= 4 ? *ptr_9 : 4;
+}
+
+void func_9_s_8()
+{
+ func_10(func_9_s_8);
+}
+
+// { dg-final { scan-tree-dump " / 0" "optimized" } }
/* If we face a dead stmt remove it as it possibly blocks
sinking of uses. */
if (zero_uses_p
- && ! gimple_vdef (stmt))
+ && !gimple_vdef (stmt)
+ && (cfun->can_delete_dead_exceptions
+ || !stmt_could_throw_p (cfun, stmt)))
{
gsi_remove (&saved, true);
release_defs (stmt);