From patchwork Tue Nov 28 04:43:26 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: 170530 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3681523vqx; Mon, 27 Nov 2023 20:44:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IH90KaZfunHyR36PdeE1UfHqMpxXrHBjenbZJDsz3fOj7TBkpGCqKTEmOharLa5hm0Beo98 X-Received: by 2002:a05:622a:1009:b0:423:74c4:34eb with SMTP id d9-20020a05622a100900b0042374c434ebmr18309761qte.20.1701146644230; Mon, 27 Nov 2023 20:44:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701146644; cv=pass; d=google.com; s=arc-20160816; b=f9+niM1AgL9vplWSyS/wSL+cMKhUzTbSOd7iZO4bKXyhlXT9L69RPsg0gKjqxI/LLC H/bTF0x+CWoFOq8HbCwhqPrG2OD1o03F7mSdVoLFWh73gN6orTYPckc6hLF+cD5nlRfu aY/CsOahNUj/+3ZjfHWIXdaqwJgzPz5cw2/VyXzltc+uZmPT0PcsEfC8hPwY7IAhaOAJ rLGUFID3kFyijJiJzplXaS2HHvYGEcapRzvoKczfaGhoq0rmyd535g6c2hohqb53hwyT lE5ZjM0bQ3a5SW1p9NW+X/Ygn3MxOL+fnsK23MOl8JbWQVo43s9OxLb1FBrGywCk4kGp IL2g== 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=0Bz3dfvcAhK39+UyaIhiHDuy+e+S6DwgN5J3sdot6vc=; fh=gk9A5O7Gbglvz1MjrRQ4hZ2i3c68kYkpOZJg1emXh+g=; b=hHMrkZeEh9Lx6zSm6Xqi8BW0dWvuD/3V8Ew2OArYqywGrGr+2eyCuhuC+lPmNocc8L OL5LGXbPsFrcz81TDu2QCocIK7eNKHU39yKkCgQVNPM5bv89+scMt6y6I5m3zVyMtmCp EbuvK0z3yRVDLXmi/WQs4lQZUUngalpN6FvQy4vJF1zysWiqDNaaNOYH5CfqxGh/8gv1 dmTUn55Z5u4WcmnoM4UFg9nWIJySFMvdTFGlW8rW89qt9szaTHh+thg93B6GyfZsS+s7 pkV0rOW8ZS7UOnZ2NJ+9ImBqqGW/vfjoJ7YRlxkjy9/Q+4AU04og49o1WlbQP+crkDXE hCFg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="aR5OcS/M"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id j3-20020ac84403000000b004239f089e33si7148376qtn.225.2023.11.27.20.44.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 20:44:04 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="aR5OcS/M"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 066F13857C46 for ; Tue, 28 Nov 2023 04:44:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by sourceware.org (Postfix) with ESMTPS id 1FF0B3858C39 for ; Tue, 28 Nov 2023 04:43:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1FF0B3858C39 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 1FF0B3858C39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701146621; cv=none; b=cKjcu08cKVu3L2XTU562kIJkkKDUSBsCGI9UVfeEAV7h2gldSfeEGAnei8KTtxuzDBHqhGwn013jjt6c9IcjCEvzl0yVqeIyB2Ep6fYj4L4aA8UP3KLv9BJVdBQ7wSo2KADwBpiAOf702Ov4c9rE9evLQjBnSV2AfH6TWR9laxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701146621; c=relaxed/simple; bh=IKmFzK199a3RBj091UKnpacLXGn78MnZVKlg2Kr5rJE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Q0nB92qR8zf4fiFpqdcunvokeAovp2+s1mUKgN2f5R6Su/rhr2ang6FQXFLdOePhb1nfmtPmVpVj458ZKKNijHqywFXlYbg+avp0pDnoCO/ueuW+hwZ6NzrM9y2Vf512Aat49L67ck2I/uWHTYdayRDe9m1IquWX9Ub9l4NtEmY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AS4ecp2003626 for ; Tue, 28 Nov 2023 04:43:39 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=0Bz3dfvcAhK39+UyaIhiHDuy+e+S6DwgN5J3sdot6vc=; b=aR5OcS/MTRXogsw73XWmWdX6b2mXmiZxM3YXZaufRcF20F2gGZRaOtXn82Gm33m3sX6J KyrN4mjeeV3CnQq5Ub4vVdTLA+h0YbMW8eJbrbf5oxy2fPWVHKw+Mtok1S8JTnvETNrP 8FpIWWCVkUJj/wwB2M5Vxxm8vfeo8pe+vWwkVvLSQpXR+VqCPu7aD3RthoSK6KeGC++U ic0wvp7NTR84LA5SlwxNMbDC8T3PO/FFMvMHM8LLyVTpdp2CbPBHApLuGRazU8AYstvm 5TCJEPERaNx/C539uxBs3Zi13BqV6jKxh/1TMfekJSw+0yKbIBw76jNdL3TT3mSEv2WI 7w== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3umsvajb31-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 28 Nov 2023 04:43:39 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AS4hcic027540 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 28 Nov 2023 04:43:38 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; Mon, 27 Nov 2023 20:43:38 -0800 From: Andrew Pinski To: Subject: [PATCH] MATCH: Fix invalid signed boolean type usage Date: Mon, 27 Nov 2023 20:43:26 -0800 Message-ID: <20231128044326.734466-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: nalasex01b.na.qualcomm.com (10.47.209.197) 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: Oh5lGWmMzoh20DWaaxl7jWdppw1SJW0R X-Proofpoint-GUID: Oh5lGWmMzoh20DWaaxl7jWdppw1SJW0R 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-28_02,2023-11-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=999 phishscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311280036 X-Spam-Status: No, score=-13.7 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_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: 1783781543572441662 X-GMAIL-MSGID: 1783781543572441662 This fixes the incorrect assumption that was done in r14-3721-ge6bcf839894783, that being able to doing the negative after the conversion would be a valid thing but really it is not valid for boolean types. OK? Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: PR tree-optimization/112738 * match.pd (`(nop_convert)-(convert)a`): Reject when the outer type is boolean. Signed-off-by: Andrew Pinski --- gcc/match.pd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 95225e4ca5f..294e58ebf44 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1033,12 +1033,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* (nop_outer_cast)-(inner_cast)var -> -(outer_cast)(var) if var is smaller in precision. This is always safe for both doing the negative in signed or unsigned - as the value for undefined will not show up. */ + as the value for undefined will not show up. + Note the outer cast cannot be a boolean type as the only valid values + are 0,-1/1 (depending on the signedness of the boolean) and the negative + is there to get the correct value. */ (simplify (convert (negate:s@1 (convert:s @0))) (if (INTEGRAL_TYPE_P (type) && tree_nop_conversion_p (type, TREE_TYPE (@1)) - && TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (@0))) + && TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (@0)) + && TREE_CODE (type) != BOOLEAN_TYPE) (negate (convert @0)))) (for op (negate abs)