From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 147073857C43; Fri, 19 Nov 2021 08:36:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 147073857C43 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5395] middle-end/103248 - fix RDIV_EXPR handling with fixed point X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 0fc859f5efcb4624a8b4ffdbf34d63972af179a8 X-Git-Newrev: fb15abdc9b61a0b7fa24a37f85d19dc449cfd5bf Message-Id: <20211119083621.147073857C43@sourceware.org> Date: Fri, 19 Nov 2021 08:36:21 +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: Fri, 19 Nov 2021 08:36:21 -0000 https://gcc.gnu.org/g:fb15abdc9b61a0b7fa24a37f85d19dc449cfd5bf commit r12-5395-gfb15abdc9b61a0b7fa24a37f85d19dc449cfd5bf Author: Richard Biener Date: Tue Nov 16 11:47:26 2021 +0100 middle-end/103248 - fix RDIV_EXPR handling with fixed point This fixes the previous adjustment to operation_could_trap_helper_p where I failed to realize that RDIV_EXPR is also used for fixed-point types. It also fixes that handling by properly checking for a fixed_zerop divisor. 2021-11-16 Richard Biener PR middle-end/103248 * tree-eh.c (operation_could_trap_helper_p): Properly handle fixed-point RDIV_EXPR. * gcc.dg/pr103248.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/pr103248.c | 8 ++++++++ gcc/tree-eh.c | 12 +++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/pr103248.c b/gcc/testsuite/gcc.dg/pr103248.c new file mode 100644 index 00000000000..da6232d21ee --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr103248.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target fixed_point } */ +/* { dg-options "-fnon-call-exceptions" } */ + +_Accum sa; +int c; + +void div_csa() { c /= sa; } diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 3eff07fc8fe..916da85af2e 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -2474,10 +2474,16 @@ operation_could_trap_helper_p (enum tree_code op, return false; case RDIV_EXPR: - if (honor_snans) + if (fp_operation) + { + if (honor_snans) + return true; + return flag_trapping_math; + } + /* Fixed point operations also use RDIV_EXPR. */ + if (!TREE_CONSTANT (divisor) || fixed_zerop (divisor)) return true; - gcc_assert (fp_operation); - return flag_trapping_math; + return false; case LT_EXPR: case LE_EXPR: