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 X-Patchwork-Id: 1869099 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=aR5OcS/M; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SfVGL5Lqpz1yRW for ; Tue, 28 Nov 2023 15:43:54 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 111953858039 for ; Tue, 28 Nov 2023 04:43:52 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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)