From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 7C460385B83A; Tue, 30 Nov 2021 10:23:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C460385B83A MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5615] Remove can_throw_non_call_exceptions special case from operator_div::wi_fold. X-Act-Checkin: gcc X-Git-Author: Aldy Hernandez X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 8af3f53d325fe4a6b1f3da64dc02d10978b9a116 X-Git-Newrev: f33fdda0b805ff6097f9f325d73a4b07e72170b0 Message-Id: <20211130102339.7C460385B83A@sourceware.org> Date: Tue, 30 Nov 2021 10:23:39 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2021 10:23:39 -0000 https://gcc.gnu.org/g:f33fdda0b805ff6097f9f325d73a4b07e72170b0 commit r12-5615-gf33fdda0b805ff6097f9f325d73a4b07e72170b0 Author: Aldy Hernandez Date: Mon Nov 29 12:52:45 2021 +0100 Remove can_throw_non_call_exceptions special case from operator_div::wi_fold. 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. Diff: --- gcc/range-op.cc | 7 ------- gcc/testsuite/gcc.dg/pr103451.c | 19 +++++++++++++++++++ gcc/tree-ssa-sink.c | 4 +++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gcc/range-op.cc b/gcc/range-op.cc index bbf2924f815..6fe5f1cb4e0 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -1832,13 +1832,6 @@ operator_div::wi_fold (irange &r, tree type, 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)) { diff --git a/gcc/testsuite/gcc.dg/pr103451.c b/gcc/testsuite/gcc.dg/pr103451.c new file mode 100644 index 00000000000..c701934603e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr103451.c @@ -0,0 +1,19 @@ +// { 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" } } diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c index 92f444ec1c8..c5d67840be3 100644 --- a/gcc/tree-ssa-sink.c +++ b/gcc/tree-ssa-sink.c @@ -696,7 +696,9 @@ sink_code_in_bb (basic_block bb) /* 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);