[Backport,GCC10] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]
Message ID | 20240401133518.714608-1-qing.zhao@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4982C3858C24 for <patchwork@sourceware.org>; Mon, 1 Apr 2024 13:35:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 71B763858D20; Mon, 1 Apr 2024 13:35:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 71B763858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 71B763858D20 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1711978526; cv=pass; b=byJ9K0iZ8bzx00d83uZ43z73kyomyilDbZ2AKTae2/D6SYr2AtzMESSb7nZBXccNFyuYQXo15544pnuMTzWqWUZR0BfUc37QkHUVoZFZOQ1Du2mAvztFV/Or5hcfmuDoWomFR+jP6ArT084fq51xllZeS5JQgrAg9w3RW++tE1k= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1711978526; c=relaxed/simple; bh=SyGJPqrsL/Y/rZu5Cc0U2d7z+XNCowgUIcP+FyUG+m4=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=WAnWWLOKHci8EF0S/f6AqDHJunvbYRdbQoxbuX4KEEo3ZIAvqIuHKzbFIvULzTbhPwjvy2M5asaaTFzXCQ4c1a9c19cL8gsmL8bgNLNw5WQxbLJHdFQseFoQ/lTqTNcJHHjC4LYyrLTgRmYvEWaNqFHNuiJ4PC3VkNq7jhevfbs= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4319TDd8009651; Mon, 1 Apr 2024 13:35:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=lSNalrPJrVCgTUUs0smCM0Kzc4AoFD6mXC1M4X9gj0E=; b=MFxXXOxBSJqobUy3iuJ/wzEg6tVSLwyY0Co/2A50iHvyf9CWLVW9AF3iBzP0Jaoa7Pkq gmnt1U1UTXuylLLFYrrTso5Xj4bypgXXzVC/NddvZSWGHoh4QqXSX4MFzD9xhI2JJMqW ndEemil6gtCn404jqtf4pphAQVwHwK8TPBgYEITqZGQwSuQYd+z4TQspgcUerxnTtVX3 PYCK2E8UfQ7WYLRVac4UUdxCvWjEiqiohQUzfuJ1rLM1dUiIltx8m89dh8LWAUTT73sQ lQhk5hob26V2rxf2LDEXXg/C1n516g8PKl/Aw2Pn/GCM6YegTEnDO6aPxExOOadyAPJd wA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3x7tb9rb0e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 01 Apr 2024 13:35:24 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 431DVv5r023319; Mon, 1 Apr 2024 13:35:23 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3x6965ca0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 01 Apr 2024 13:35:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RbB014LTbfogj8FT7ixzVOvo8hbTYdPxSQk57etKdiyxSf07yZkJlbc6VHYLtvPY7vTyvZPaiaiR2UFCLODt2zUYFnp31O5tctmiqPyOHb7mR+Wu/lXBWMQN/NS3bJmQ5KTDR5gaarziFXr649WVBR+dnKxS9POk6MiPNttstXE9+1U4MNTzi9MLOpEOBhPfPYMcHdkDZl2dn9NEAssCjseS5N7VZD9BoXyOVFZWpqiKFCE3P/cLDXhZdDf7Wk5qOOw2VxAyjkNayTa9CW0U348vdFVJxL3jTgyBGasVGX9R8BYMKiBJEcNkaWdCfJe0OqTiN67Fy7Gh674p8HgDFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lSNalrPJrVCgTUUs0smCM0Kzc4AoFD6mXC1M4X9gj0E=; b=hReoxdDlD73HTyFNi/2XxhX7ihkTN+n7uuJD/BNSeNifIEL38+j62L2QL95PabdnFBD/ldCeR5hKrBNbCCyj2/DaiyOtR4ectpw6RUjFbEKG01jhrQ/eOZ8hL6JLtvNYOicvLlBmyVXpGSjoPchVlvX1waHFImkN78CQgA9Pf7P6zFnHgVl7dwV/9MMknGi9HElgHKlgHOCWDfOh62srLLv/rp+gFmTMnLIuisvQWE+KK3086XOyNNwxWF9CkuB/KID9xD59lOOVC97lKJ4boF76SXOPqmi2Se+bBndIhrCwXR3wJAr5R+j9TMddYxchFOpHrhZgxl1XV0zBi4kFpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lSNalrPJrVCgTUUs0smCM0Kzc4AoFD6mXC1M4X9gj0E=; b=UPej+CsWpkAaQPk/McorQ3SEMKBNw6c1OJGpQnMn3ssm/3CwTXHL6heIf66tb9GXMhUH4+RZY/jvPDaWyMxyv0I+RXYoBWZbI0By4CBdUV8HpsQ6EbkdZZvRohoOekpcQz70QMcwmwLofmSweCRkbmTF7DBEUiu107FJR3iAU3I= Received: from CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) by LV8PR10MB7799.namprd10.prod.outlook.com (2603:10b6:408:1ec::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Mon, 1 Apr 2024 13:35:21 +0000 Received: from CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc]) by CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc%6]) with mapi id 15.20.7409.042; Mon, 1 Apr 2024 13:35:21 +0000 From: Qing Zhao <qing.zhao@oracle.com> To: gcc-patches@gcc.gnu.org Cc: pinskia@gcc.gnu.org, Qing Zhao <qing.zhao@oracle.com> Subject: [PATCH][Backport][GCC10] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407] Date: Mon, 1 Apr 2024 13:35:18 +0000 Message-Id: <20240401133518.714608-1-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR05CA0160.namprd05.prod.outlook.com (2603:10b6:a03:339::15) To CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB6538:EE_|LV8PR10MB7799:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I7co75/bH+6wY+avMhtJmu5Nt6xwJAtSZ7xjcPuNvp+rnIE6Y9fie3ez5FWsu3JEjJpTdPDR0XwHFO95ANKS+B9MvwN8WNI7e3onqfH33jegOvD7+P5WxPZ8xBR8p7fEYUYAeLlPekDCvmp+lBxk+gihWyKljfKe1v+jd+pn6Bnr0n7QhSU+ApqwXH7mSSIAsuUbPrFkKeDyk9+0fiOt7KRuzmrLDSRaxxKvgN9Zz2gCkzP97g7NVT2lt1SvdILIjKl6A/JrIill1mCWulb41ZSSYcQAYLj1Tuq2gf5bsKDcGAR7HWaw80NnB2BVXcpx9JpmO3bwra8qh8iQfMnRHPm6n08kdUAgK2WpZGHkrfV81ZV1NKgaobkasza2djCCDmHCvaYF54egG45+UzzBFNecUy6uNXHLC55NPEler2NgwyUy6dk98F31ZFUAJT3SYdGGtUMpC0z1hV9S4lBmGCtKkvsZD3jKThezAb+kubqlafZ6zDV8qcDMSYeR/3HLFivr8LufJm0WuO8pJvkr7+FDreGllYUv+n0SxO3uuo9573AR9tzAdbxHGadpSI5LC1DoLJfPbm+BO90o4+/fcsWSZ7a2iamCTB+tTMpP8Q4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY8PR10MB6538.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(376005)(1800799015); DIR:OUT; SFP:1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/84H+Vmv0ZBkGHDl6qv9YbTn70kvHx8L45f1Io+wUyVV9auFsjuyUQcuppZDsbJy4Y5tECKx8JzMRyyCT/6OgoEgUlgxewg0InKgvL0Nr6S4EPQ4p5H+3Q8A+H/A9syJUEDF2H8k8iQfYPKMCuU+Gc3+TUqJdG3vkxL3uwLigBXdyu/ZVjITlfUQ6H4m9YURbVCb+Lig= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62655432-ed15-4a97-31d5-08dc5250940b X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB6538.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2024 13:35:21.5378 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wiH4d3sBzASQrQHRGYI32TIDoYB2vW8+NWSfk3IQZc8Y4BQj6NxsQHpzYHhvY2ckro7iXI6ge9hJ1gp/2rhyfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR10MB7799 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-01_09,2024-04-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=949 bulkscore=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2404010096 X-Proofpoint-GUID: V8UuMY_WxgtTFKnZ_cCZUImg4moY6pNu X-Proofpoint-ORIG-GUID: V8UuMY_WxgtTFKnZ_cCZUImg4moY6pNu X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org |
Series |
[Backport,GCC10] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407]
|
|
Checks
Context | Check | Description |
---|---|---|
linaro-tcwg-bot/tcwg_gcc_build--master-arm | warning | Patch is already merged |
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 | warning | Patch is already merged |
Commit Message
Qing Zhao
April 1, 2024, 1:35 p.m. UTC
This is a bug in tree-ssa-math-opts.c, when applying the widening mul optimization, the compiler needs to check whether the operand is in a ABNORMAL PHI, if YES, we should avoid the transformation. PR tree-optimization/111407 gcc/ChangeLog: * tree-ssa-math-opts.c (convert_mult_to_widen): Avoid the transform when one of the operands is subject to abnormal coalescing. gcc/testsuite/ChangeLog: * gcc.dg/pr111407.c: New test. (cherry picked from commit 4aca1cfd6235090e48a53dab734437740671bbf3) bootstraped and regression tested on both aarch64 and x86. Okay for commit to GCC10? thanks. Qing --- gcc/testsuite/gcc.dg/pr111407.c | 21 +++++++++++++++++++++ gcc/tree-ssa-math-opts.c | 8 ++++++++ 2 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr111407.c
Comments
On Mon, Apr 1, 2024 at 3:36 PM Qing Zhao <qing.zhao@oracle.com> wrote: > > This is a bug in tree-ssa-math-opts.c, when applying the widening mul > optimization, the compiler needs to check whether the operand is in a > ABNORMAL PHI, if YES, we should avoid the transformation. > > PR tree-optimization/111407 > > gcc/ChangeLog: > > * tree-ssa-math-opts.c (convert_mult_to_widen): Avoid the transform > when one of the operands is subject to abnormal coalescing. > > gcc/testsuite/ChangeLog: > > * gcc.dg/pr111407.c: New test. > > (cherry picked from commit 4aca1cfd6235090e48a53dab734437740671bbf3) > > bootstraped and regression tested on both aarch64 and x86. > > Okay for commit to GCC10? Note the GCC 10 branch is closed. If the patch boostraps/tests on the 11, 12 and 13 branches it is OK there. You do not need approval to backport fixes for _regressions_ if the patch cherry-picks without major edits and boostraps/tests OK. Thanks, Richard. > thanks. > > Qing > --- > gcc/testsuite/gcc.dg/pr111407.c | 21 +++++++++++++++++++++ > gcc/tree-ssa-math-opts.c | 8 ++++++++ > 2 files changed, 29 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/pr111407.c > > diff --git a/gcc/testsuite/gcc.dg/pr111407.c b/gcc/testsuite/gcc.dg/pr111407.c > new file mode 100644 > index 000000000000..a171074753f9 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr111407.c > @@ -0,0 +1,21 @@ > +/* PR tree-optimization/111407*/ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > +enum { SEND_TOFILE } __sigsetjmp(); > +void fclose(); > +void foldergets(); > +void sendpart_stats(int *p1, int a1, int b1) { > + int *a = p1; > + fclose(); > + p1 = 0; > + long t = b1; > + if (__sigsetjmp()) { > + { > + long t1 = a1; > + a1+=1; > + fclose(a1*(long)t1); > + } > + } > + if (p1) > + fclose(); > +} > diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c > index dd0b8c6f0577..47981da20e05 100644 > --- a/gcc/tree-ssa-math-opts.c > +++ b/gcc/tree-ssa-math-opts.c > @@ -2543,6 +2543,14 @@ convert_mult_to_widen (gimple *stmt, gimple_stmt_iterator *gsi) > if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2)) > return false; > > + /* if any one of rhs1 and rhs2 is subject to abnormal coalescing, > + avoid the tranform. */ > + if ((TREE_CODE (rhs1) == SSA_NAME > + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)) > + || (TREE_CODE (rhs2) == SSA_NAME > + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs2))) > + return false; > + > to_mode = SCALAR_INT_TYPE_MODE (type); > from_mode = SCALAR_INT_TYPE_MODE (type1); > if (to_mode == from_mode) > -- > 2.31.1 >
On Apr 2, 2024, at 03:06, Richard Biener <richard.guenther@gmail.com> wrote: On Mon, Apr 1, 2024 at 3:36 PM Qing Zhao <qing.zhao@oracle.com<mailto:qing.zhao@oracle.com>> wrote: This is a bug in tree-ssa-math-opts.c, when applying the widening mul optimization, the compiler needs to check whether the operand is in a ABNORMAL PHI, if YES, we should avoid the transformation. PR tree-optimization/111407 gcc/ChangeLog: * tree-ssa-math-opts.c (convert_mult_to_widen): Avoid the transform when one of the operands is subject to abnormal coalescing. gcc/testsuite/ChangeLog: * gcc.dg/pr111407.c: New test. (cherry picked from commit 4aca1cfd6235090e48a53dab734437740671bbf3) bootstraped and regression tested on both aarch64 and x86. Okay for commit to GCC10? Note the GCC 10 branch is closed. If the patch boostraps/tests on the 11, 12 and 13 branches it is OK there. You do not need approval to backport fixes for _regressions_ if the patch cherry-picks without major edits and boostraps/tests OK. Thanks for the info. I will commit the patches for GCC11, 12, and 13 soon. Qing Thanks, Richard. thanks. Qing --- gcc/testsuite/gcc.dg/pr111407.c | 21 +++++++++++++++++++++ gcc/tree-ssa-math-opts.c | 8 ++++++++ 2 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr111407.c diff --git a/gcc/testsuite/gcc.dg/pr111407.c b/gcc/testsuite/gcc.dg/pr111407.c new file mode 100644 index 000000000000..a171074753f9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr111407.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/111407*/ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +enum { SEND_TOFILE } __sigsetjmp(); +void fclose(); +void foldergets(); +void sendpart_stats(int *p1, int a1, int b1) { + int *a = p1; + fclose(); + p1 = 0; + long t = b1; + if (__sigsetjmp()) { + { + long t1 = a1; + a1+=1; + fclose(a1*(long)t1); + } + } + if (p1) + fclose(); +} diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index dd0b8c6f0577..47981da20e05 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -2543,6 +2543,14 @@ convert_mult_to_widen (gimple *stmt, gimple_stmt_iterator *gsi) if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2)) return false; + /* if any one of rhs1 and rhs2 is subject to abnormal coalescing, + avoid the tranform. */ + if ((TREE_CODE (rhs1) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)) + || (TREE_CODE (rhs2) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs2))) + return false; + to_mode = SCALAR_INT_TYPE_MODE (type); from_mode = SCALAR_INT_TYPE_MODE (type1); if (to_mode == from_mode) -- 2.31.1
diff --git a/gcc/testsuite/gcc.dg/pr111407.c b/gcc/testsuite/gcc.dg/pr111407.c new file mode 100644 index 000000000000..a171074753f9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr111407.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/111407*/ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +enum { SEND_TOFILE } __sigsetjmp(); +void fclose(); +void foldergets(); +void sendpart_stats(int *p1, int a1, int b1) { + int *a = p1; + fclose(); + p1 = 0; + long t = b1; + if (__sigsetjmp()) { + { + long t1 = a1; + a1+=1; + fclose(a1*(long)t1); + } + } + if (p1) + fclose(); +} diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index dd0b8c6f0577..47981da20e05 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -2543,6 +2543,14 @@ convert_mult_to_widen (gimple *stmt, gimple_stmt_iterator *gsi) if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2)) return false; + /* if any one of rhs1 and rhs2 is subject to abnormal coalescing, + avoid the tranform. */ + if ((TREE_CODE (rhs1) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)) + || (TREE_CODE (rhs2) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs2))) + return false; + to_mode = SCALAR_INT_TYPE_MODE (type); from_mode = SCALAR_INT_TYPE_MODE (type1); if (to_mode == from_mode)