From patchwork Mon Apr 24 21:30:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 87166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3015934vqo; Mon, 24 Apr 2023 14:31:59 -0700 (PDT) X-Google-Smtp-Source: AKy350Y6H7GwoGDgsJbd7GkzmXPOj7qXqC77FbY2qjCV7YJRh2vHgNY/uFInmZBpzvQcTJQ3N/01 X-Received: by 2002:a05:6402:1614:b0:506:82b7:10c3 with SMTP id f20-20020a056402161400b0050682b710c3mr11953863edv.41.1682371919542; Mon, 24 Apr 2023 14:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682371919; cv=none; d=google.com; s=arc-20160816; b=YV05QRso7u8Yof7vz9J+pb0T0DedoLOQUqb81mYRkcy5X5FSQgfBWn7E3yC8LoFZHd uwNnfvZS+iGoii9PIIZ2xngMP80utlLqmKL4qinqE4rI7jsbGZNZ9Mhf+uLUxMGDdmB4 QfCN3QTtOo9Jj+VCGaTGmaF3QaZj6iGWn+QQp5nJCTRNUqHSiLxHqhhIov+v4fKeARm6 EBIVHiHEGC5zDdmidoAAWWR/P1eo1szOomCaSEskDCkt52ORC73gHpF3nxhmSxwj1GdI LoL+t0/2qvZbfhNuKAWzUrKTVO7+dEF7auva2tDz1dhhgDxnXuvjAO61vGB0Oe1lB92W Nj/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=94wiAQZo024aniwILV77QAcfcAeJobhoSZFvpIPegy8=; b=0dyPFkxEtnGADTcizK9V0Ddmq4r0+dx78GKEXAFvL4uHUS4BzH8wRyBscoEvK3FGoc J0QI67KJqr2XG+r0G+GrWIPV0EKXhIlid7pIvVWv2YfNIfxfvAtfbonwkoMPVDU7V/Og 46c8L+tZOAvJlrOEYbuPnL4LiW9vps69hBVqcG4LmfWa+CAyHP0rHZjZWQrYJZ+x63sN yMsT3AcjPauESQdR8TwAYHI5NHF5OQ2Vv4tUb769LKMAGEXB/JqUMDxyIxWmNKrcZZvq A/52jh29pSDjNqaoCz3mU1J7ndceMFLT9g75GUwSwh5uikVktukeCnfPf1ksIzb2HTEU 4u6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kLSQJpBR; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id b4-20020a05640202c400b0050506788181si8932813edx.139.2023.04.24.14.31.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 14:31:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kLSQJpBR; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 15A813856DFC for ; Mon, 24 Apr 2023 21:31:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 15A813856DFC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682371870; bh=94wiAQZo024aniwILV77QAcfcAeJobhoSZFvpIPegy8=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=kLSQJpBRWL09DZUJbbn6cuajD7iuBwOYVD6sv58J+TD6d52Z3Op2shHm5HmhS5q8E 3m6agO6e4mueEkHVJzbc6oMD1q2rp5SwpQlYlPtajKPBqRKxDTxhJQwzsq3To8bqMv oSwrFYsgNwLPqq8sgPSoMDnkZdHm5YYQWeC7aZ1g= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by sourceware.org (Postfix) with ESMTPS id 2705F3858C83 for ; Mon, 24 Apr 2023 21:30:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2705F3858C83 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33OGXiZx028418 for ; Mon, 24 Apr 2023 14:30:23 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3q5nfb3jvs-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 24 Apr 2023 14:30:23 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 24 Apr 2023 14:30:21 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Mon, 24 Apr 2023 14:30:21 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id E5D293F70B3; Mon, 24 Apr 2023 14:30:20 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH 4/7] MIN/MAX should be treated similar as comparisons for trapping Date: Mon, 24 Apr 2023 14:30:08 -0700 Message-ID: <20230424213011.528181-5-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230424213011.528181-1-apinski@marvell.com> References: <20230424213011.528181-1-apinski@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: bJiRkb7_o4-akgCKuQk1SOSfslCdzXOc X-Proofpoint-GUID: bJiRkb7_o4-akgCKuQk1SOSfslCdzXOc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-24_11,2023-04-21_01,2023-02-09_01 X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Pinski via Gcc-patches From: Andrew Pinski Reply-To: Andrew Pinski Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764094818072075636?= X-GMAIL-MSGID: =?utf-8?q?1764094818072075636?= While looking into moving optimizations from minmax_replacement in phiopt to match.pd, I Noticed that min/max were considered trapping even if -ffinite-math-only was being used. This changes those expressions to be similar as comparisons so that they are not considered trapping if -ffinite-math-only is on. OK? Bootstrapped and tested with no regressions on x86_64-linux-gnu. gcc/ChangeLog: * rtlanal.cc (may_trap_p_1): Treat SMIN/SMAX similar as COMPARISON. * tree-eh.cc (operation_could_trap_helper_p): Treate MIN_EXPR/MAX_EXPR similar as other comparisons. --- gcc/rtlanal.cc | 3 +++ gcc/tree-eh.cc | 3 +++ 2 files changed, 6 insertions(+) diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc index c96a88cebf1..b7948ecfad1 100644 --- a/gcc/rtlanal.cc +++ b/gcc/rtlanal.cc @@ -3204,6 +3204,9 @@ may_trap_p_1 (const_rtx x, unsigned flags) case LT: case LTGT: case COMPARE: + /* Treat min/max similar as comparisons. */ + case SMIN: + case SMAX: /* Some floating point comparisons may trap. */ if (!flag_trapping_math) break; diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc index 41cf57d2b30..dbaa27d95c5 100644 --- a/gcc/tree-eh.cc +++ b/gcc/tree-eh.cc @@ -2490,6 +2490,9 @@ operation_could_trap_helper_p (enum tree_code op, case GT_EXPR: case GE_EXPR: case LTGT_EXPR: + /* MIN/MAX similar as LT/LE/GT/GE. */ + case MIN_EXPR: + case MAX_EXPR: /* Some floating point comparisons may trap. */ return honor_nans;