From patchwork Mon Apr 27 22:30:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 1278030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=ALutyTaE; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 499zxl6G4Sz9sSJ for ; Tue, 28 Apr 2020 08:30:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D4BD0385DC00; Mon, 27 Apr 2020 22:30:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4BD0385DC00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588026633; bh=0ebaSBxYCadJBc742fqKi8GVnqRPfid1/hEmCs30Uk0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ALutyTaEFduw1HwO9Og86tFiL5ho6tzvGrF58V4E+zKlgQBai6438kjxPgY3Xq2cu W49mBqgO9m9B4do5K6dsgI7Xw3ZdbG7DoRD+lhIobRmes+MGmuU4NXXmMELh+lu1up UHDIcDCjoeq+d1qKjeV8HpP1OBqQNsUnBl4wvGOM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id DD9153858D35 for ; Mon, 27 Apr 2020 22:30:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DD9153858D35 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03RM3rNE110824; Mon, 27 Apr 2020 18:30:28 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 30mhbhvrmb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Apr 2020 18:30:27 -0400 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 03RM8d4Q121479; Mon, 27 Apr 2020 18:30:27 -0400 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0b-001b2d01.pphosted.com with ESMTP id 30mhbhvrky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Apr 2020 18:30:27 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 03RMU9Up026408; Mon, 27 Apr 2020 22:30:27 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma05wdc.us.ibm.com with ESMTP id 30mcu66rm0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Apr 2020 22:30:26 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 03RMUQeA24314240 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Apr 2020 22:30:26 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 055536A058; Mon, 27 Apr 2020 22:30:26 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1DFBD6A057; Mon, 27 Apr 2020 22:30:25 +0000 (GMT) Received: from [9.160.59.87] (unknown [9.160.59.87]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 27 Apr 2020 22:30:24 +0000 (GMT) To: GCC Patches Subject: [PATCH] rtl cse: Fix PR94740, ICE on testsuite/gcc.dg/sso/t5.c with -mcpu=future -mpcrel -O1 Message-ID: <6748c592-4a51-604c-8dd1-c5f2bae5b5da@linux.ibm.com> Date: Mon, 27 Apr 2020 17:30:24 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-27_17:2020-04-27, 2020-04-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 spamscore=0 clxscore=1011 priorityscore=1501 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004270180 X-Spam-Status: No, score=-18.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Peter Bergner via Gcc-patches From: Peter Bergner Reply-To: Peter Bergner Cc: Eric Botcazou , Segher Boessenkool Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" rtl-optimization: ICE on testsuite/gcc.dg/sso/t5.c with -mcpu=future -mpcrel -O1 [PR94740] We ICE on the test case below because decompose_normal_address() doesn't expect to see memory operands with constant addresses like below without a (const:DI ...) wrapped around the PLUS: (mem/c:SI (plus:DI (symbol_ref:DI ("*.LANCHOR0") [flags 0x182]) (const_int 4 [0x4])) [1 array+4 S4 A32]) What we expect to see is: (mem/c:SI (const:DI (plus:DI (symbol_ref:DI ("*.LANCHOR0") [flags 0x182]) (const_int 4 [0x4]))) [1 arrayD.2903+4 S4 A32]) Sometimes, combine adds the (const: ...) for us via simplify_binary_operand call, but that only happens when combine actually does something with this insn. The bad address from the test case actually comes from CSE, so the fix here is to make CSE add the (const: ...) whenever it creates a MEM with a constant address. This passed bootstrap and regtesting on powerpc64le-linux with no regressions. Ok for trunk? Peter gcc/ PR rtl-optimization/94740 * cse.c (cse_process_notes): gcc/testsuite/ PR rtl-optimization/94740 * gcc.target/powerpc/pr94740.c: New test. diff --git a/gcc/cse.c b/gcc/cse.c index 5aaba8d80e0..cbe9e0a0692 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -6328,6 +6328,14 @@ cse_process_notes (rtx x, rtx object, bool *changed) rtx new_rtx = cse_process_notes_1 (x, object, changed); if (new_rtx != x) *changed = true; + if (*changed && object != NULL_RTX && MEM_P (object)) + { + /* Call simplify_rtx on the updated address in case it is now + a constant and needs to be wrapped with a (const: ...). */ + rtx simplified_rtx = simplify_rtx (new_rtx); + if (simplified_rtx) + new_rtx = simplified_rtx; + } return new_rtx; } diff --git a/gcc/testsuite/gcc.target/powerpc/pr94740.c b/gcc/testsuite/gcc.target/powerpc/pr94740.c new file mode 100644 index 00000000000..78e40fc84da --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr94740.c @@ -0,0 +1,11 @@ +/* PR rtl-optimization/94740 */ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_future_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=future -mpcrel" } */ + +int array[8]; +int +foo (void) +{ + return __builtin_bswap32 (array[1]); +}