From patchwork Mon Nov 27 04:33:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andrew Pinski (QUIC)" X-Patchwork-Id: 169967 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp2847318vqx; Sun, 26 Nov 2023 20:34:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IH90nqnQi6Lan0mGiov1rgxYDl2YusfRhHDyZTyeJucQ1RRX2RSJ25sQqJoesr+zT9WYOxN X-Received: by 2002:a0c:ef06:0:b0:67a:262e:f87 with SMTP id t6-20020a0cef06000000b0067a262e0f87mr6915644qvr.20.1701059657466; Sun, 26 Nov 2023 20:34:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701059657; cv=pass; d=google.com; s=arc-20160816; b=uB5VxUEAHBLzVN4pYfEPg3P2PonZ+8By4Q5LZfPe8HpKXRl/+WdEYxYZ9Pyxya7/L7 ISET6p5pTXBUcpkEa7ln6pt/f0OPMEIfd6Z3KJpQ3VQrC87NdYKN96EUYg87mrhlMNtT C6qTj9St/QUl30gfUMSNrTb2GBH+hX6CYIAgsjCqjjiVGoH+o57maor74Sh54jZmSRmv iTDCOyYvCV34L7aOF8OMhE/A1X8LlvoxY3u/5EbH6BTlUo/ySxvkZKW7bm/x5nvGz459 zr7BTfZQJ6EE+N+9cW8uVm6cWxlPJEBZbxN5WYmY/I6V0CNWo1gVpx0jFFH5fvhYlV/g 563Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=kA+PT/quHgq52Bcpi8+M0CDP0DSy4o27WAdfBMuvrQM=; fh=gk9A5O7Gbglvz1MjrRQ4hZ2i3c68kYkpOZJg1emXh+g=; b=YMLsyuMGgx48QkvyCOci0e6w92g3RaujhjjgQ/ICXFgVIo1CSIs8lSoDAeejN9RDIu qT6CUymQLmzIwPEWcmPBG1n9Wa+hZL+FD/Wld+gQPGRQLUzjvbFYVMojGSSZbYQSsYn9 rgZRMpBrCaRN5cxl2Q4EIxC0dr3d+6kT4PKzioRcpT/ru5m6yziZHb9fye1+mq5RsU/t F9xZe1rQCTquOyHZA4tSVYi8djDB1V4RqnsNV6CkUXYG7a7gRl6wR3eyJsPeobPNYqTf bhNcFBphohr7cIJ7oftryIfTQ5zHgzxl4TTjtSxORiugU1rRTinZIHdxLxreivecWhLg vWNg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=gyRleUE7; arc=pass (i=1); 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=quicinc.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 6-20020a0562140d4600b0067a3f411241si2083664qvr.418.2023.11.26.20.34.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 20:34:17 -0800 (PST) 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=@quicinc.com header.s=qcppdkim1 header.b=gyRleUE7; arc=pass (i=1); 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=quicinc.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3D5183858290 for ; Mon, 27 Nov 2023 04:34:17 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by sourceware.org (Postfix) with ESMTPS id E4AAC3858D33 for ; Mon, 27 Nov 2023 04:33:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E4AAC3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E4AAC3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701059634; cv=none; b=i4Q+AFa6zfUyAKJyCQmlw+avTTiHz13Ph2hCoxd5xlfrrk2xapogPxreWFS0nS86k/pxqqWizZo/y8kOuUPK9wGfLPZgQvBcJ+hUffwcCge9qX5gncAoOa6iRDtFy6eN7m8mqF0a/AoydimyreutuIcqZhoyOPwmoJs2jTPEFuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701059634; c=relaxed/simple; bh=G9ZFabytDZ0RRS0zTRSuTk1U4+eVAOW7W5Ov+JSooBw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uvqictccMtRQMqu0c0RAxND6EDGDmOtkMdztvO+JZw8D8IwdD0fhE/PVMIbrUDxk/KHHebaOuyfRIixinhoBWKDjdgn3Hay+OYGvNeDd0DPEv5yd9N6wFPruand7f5ZUN1cXYYgH2DJLLwBjLd4ui0hpgBqfYPzTAY/dLyKiTZY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AR32xhT013780 for ; Mon, 27 Nov 2023 04:33:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=kA+PT/quHgq52Bcpi8+M0CDP0DSy4o27WAdfBMuvrQM=; b=gyRleUE71afcjzdfDZfhZNGo79IcH+k3ulei1gXjDBBQU2CziXhz+U0mj2zoi7JPMqXe tM3HFjBNb/01OGfMGV+RsRaj8ONDHUycZk0Ay5KMV4q1y5QzchBaQVVCenjTHONmzcWP ATa5dyfaxTJCWCwNm9gJAbv1sQkq7lKwqvMpdLTnre9Sp2i4DjSsAPB2caT8OnSgX2xL kgTCh4JZm0LLAN5D15eE6XNxbPPhwxr4nftGO98n/hwInckRagzamV7WAlPwVbRM/agq r/4XaFRh90hJtIglRK0CECuWPDCfNZ43N9L+iIuCPCV5MAtd3zUI3+XZD681xO98LThI WQ== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uk69ubetg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Nov 2023 04:33:50 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AR4XmCr003298 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Nov 2023 04:33:48 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Sun, 26 Nov 2023 20:33:48 -0800 From: Andrew Pinski To: Subject: [PATCH] aarch64: Improve cost of `a ? {-,}1 : b` Date: Sun, 26 Nov 2023 20:33:33 -0800 Message-ID: <20231127043333.1955900-1-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: ba9q6Fw2noggF2YmV7vEZO47_4Aq12hQ X-Proofpoint-GUID: ba9q6Fw2noggF2YmV7vEZO47_4Aq12hQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-26_25,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=466 mlxscore=0 phishscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311270032 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783690331267077388 X-GMAIL-MSGID: 1783690331267077388 While looking into PR 112454, I found the cost for `(if_then_else (cmp) (const_int 1) (reg))` was being recorded as 8 (or `COSTS_N_INSNS (2)`) but it should have been 4 (or `COSTS_N_INSNS (1)`). This improves the cost by not adding the cost of `(const_int 1)` to the total cost. It does not does not fix PR 112454 as that requires other changes to forwprop the `(const_int 1)` earlier than combine. Bootstrapped and tested on aarch64-linux-gnu with no regressions. gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_if_then_else_costs): Don't add the cost of `1` or `-1`. Signed-off-by: Andrew Pinski --- gcc/config/aarch64/aarch64.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index f6f6f94bf43..63241c5aaa5 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -11642,9 +11642,16 @@ aarch64_if_then_else_costs (rtx op0, rtx op1, rtx op2, int *cost, bool speed) /* CSINV/NEG with zero extend + const 0 (*csinv3_uxtw_insn3). */ op1 = XEXP (inner, 0); } - - *cost += rtx_cost (op1, VOIDmode, IF_THEN_ELSE, 1, speed); - *cost += rtx_cost (op2, VOIDmode, IF_THEN_ELSE, 2, speed); + if (op2 == constm1_rtx || op2 == const1_rtx) + *cost += rtx_cost (op1, VOIDmode, IF_THEN_ELSE, 1, speed); + else if (op1 == constm1_rtx || op1 == const1_rtx) + *cost += rtx_cost (op2, VOIDmode, IF_THEN_ELSE, 2, speed); + else + { + *cost += rtx_cost (op1, VOIDmode, IF_THEN_ELSE, 1, speed); + *cost += rtx_cost (op2, VOIDmode, IF_THEN_ELSE, 1, speed); + } + return true; }