From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 835DF384F020; Wed, 31 Jan 2024 10:15:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 835DF384F020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706696142; bh=SJ3Ty5k3VCcQyay36OQnMc97UH7LkkEyCZwGmU0zF88=; h=From:To:Subject:Date:From; b=y5hrCFrHPwM3YqtiETBV34dvrh6koyCM41PL7J9GxcV+RdnvibQw7u82WdgP7eIxe +k2t/cQEB5KMq9ESxOam/HerlZYNSkWqdObL/nslwMCES99k0XZrfsaJo3B0Ki/UqK onKIl17W/DCbFFx3bubW5s8VfMG6NcX5ZCbwdvG0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8652] simplify-rtx: Fix up last argument to simplify_gen_unary [PR113656] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 457d2b59b58e5998e1e6967316d4e3e8f24edeed X-Git-Newrev: b59775b642bb2b1ecd2e6d52c988b9c432117bc8 Message-Id: <20240131101542.835DF384F020@sourceware.org> Date: Wed, 31 Jan 2024 10:15:42 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b59775b642bb2b1ecd2e6d52c988b9c432117bc8 commit r14-8652-gb59775b642bb2b1ecd2e6d52c988b9c432117bc8 Author: Jakub Jelinek Date: Wed Jan 31 10:56:56 2024 +0100 simplify-rtx: Fix up last argument to simplify_gen_unary [PR113656] When simplifying e.g. (float_truncate:SF (float_truncate:DF (reg:XF)) or (float_truncate:SF (float_extend:XF (reg:DF)) etc. into (float_truncate:SF (reg:XF)) or (float_truncate:SF (reg:DF)) we call simplify_gen_unary with incorrect op_mode argument, it should be the argument's mode, but we call it with the outer mode instead. As these are all floating point operations, the argument always has non-VOIDmode and so we can just use that mode (as done in similar simplifications a few lines later), but neither FLOAT_TRUNCATE nor FLOAT_EXTEND are operations that should have the same modes of operand and result. This bug hasn't been a problem for years because normally op_mode is used only if the mode of op is VOIDmode, otherwise it is redundant, but r10-2139 added an assertion in some spots that op_mode is right even in such cases. 2024-01-31 Jakub Jelinek PR rtl-optimization/113656 * simplify-rtx.cc (simplify_context::simplify_unary_operation_1) : Fix up last argument to simplify_gen_unary. * gcc.target/i386/pr113656.c: New test. Diff: --- gcc/simplify-rtx.cc | 2 +- gcc/testsuite/gcc.target/i386/pr113656.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc index c7215cfad2aa..36dd52279178 100644 --- a/gcc/simplify-rtx.cc +++ b/gcc/simplify-rtx.cc @@ -1305,7 +1305,7 @@ simplify_context::simplify_unary_operation_1 (rtx_code code, machine_mode mode, > GET_MODE_UNIT_SIZE (mode) ? FLOAT_TRUNCATE : FLOAT_EXTEND, mode, - XEXP (op, 0), mode); + XEXP (op, 0), GET_MODE (XEXP (op, 0))); /* (float_truncate (float x)) is (float x) */ if ((GET_CODE (op) == FLOAT || GET_CODE (op) == UNSIGNED_FLOAT) diff --git a/gcc/testsuite/gcc.target/i386/pr113656.c b/gcc/testsuite/gcc.target/i386/pr113656.c new file mode 100644 index 000000000000..fa57a56bfc8d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr113656.c @@ -0,0 +1,12 @@ +/* PR rtl-optimization/113656 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -frounding-math -funsafe-math-optimizations -mavx512fp16 -mavx512vl" } */ + +_Float16 a[8]; + +void +foo () +{ + for (int i = 0; i < 8; i++) + a[i] = i - 8.4; +}