From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 430613851C07; Thu, 17 Sep 2020 14:24:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 430613851C07 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1600352650; bh=clbPX8DiSAm1gcjZKwYWB8MD9Yu827N7/6RGcOpLoas=; h=From:To:Subject:Date:From; b=mPpWcWbqn2rhj7H0jDIvIrBXCNssAEWp3A5Z4NxH4YIrgi670BogovunMEomVJu1o qmr5UpDhwyUJhvnPoYB0m1V4tum1mkvTzHdkxeSRg6nOhjvTU8nvoEY3l4MGcKW4Qt ORqTf2lJs+CDrxEYFDHf/yH4hyt/LkyrzF2Evndw= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r8-10455] explow: Fix ICE caused by plus_constant [PR94002] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-8 X-Git-Oldrev: e1fdce3a0d7064957639949a1ab0fe4a282012c8 X-Git-Newrev: 3549a5cabdfd4ebb197da99f247d0abad0ba55b5 Message-Id: <20200917142410.430613851C07@sourceware.org> Date: Thu, 17 Sep 2020 14:24:10 +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: Thu, 17 Sep 2020 14:24:10 -0000 https://gcc.gnu.org/g:3549a5cabdfd4ebb197da99f247d0abad0ba55b5 commit r8-10455-g3549a5cabdfd4ebb197da99f247d0abad0ba55b5 Author: Jakub Jelinek Date: Tue Mar 3 10:42:34 2020 +0100 explow: Fix ICE caused by plus_constant [PR94002] The following testcase ICEs in cross to riscv64-linux. The problem is that we have a DImode integral constant (that doesn't fit into SImode), which is pushed into a constant pool and later access just the first half of it using a MEM. When plus_constant is called on such a MEM, if the constant has mode, we verify the mode, but if it doesn't, we don't and ICE later on when we think the CONST_INT is a valid SImode constant. 2020-03-03 Jakub Jelinek PR rtl-optimization/94002 * explow.c (plus_constant): Punt if cst has VOIDmode and get_pool_mode is different from mode. * gcc.dg/pr94002.c: New test. (cherry picked from commit e913d4f4771e04d4254bf6c0e720fec5e324a898) Diff: --- gcc/explow.c | 3 +++ gcc/testsuite/gcc.dg/pr94002.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/gcc/explow.c b/gcc/explow.c index 72e52703c48..79c781cb390 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -129,6 +129,9 @@ plus_constant (machine_mode mode, rtx x, poly_int64 c, bool inplace) cst = gen_lowpart (mode, cst); gcc_assert (cst); } + else if (GET_MODE (cst) == VOIDmode + && get_pool_mode (XEXP (x, 0)) != mode) + break; if (GET_MODE (cst) == VOIDmode || GET_MODE (cst) == mode) { tem = plus_constant (mode, cst, c); diff --git a/gcc/testsuite/gcc.dg/pr94002.c b/gcc/testsuite/gcc.dg/pr94002.c new file mode 100644 index 00000000000..05a02f3f15b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr94002.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/94002 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-dce -fno-tree-reassoc" } */ +/* { dg-additional-options "-fPIC" { target fpic } } */ + +unsigned a, b; + +void +foo (void) +{ + __builtin_sub_overflow (b, 44852956282LL, &a); + a += ~b; +}