From patchwork Thu Jan 25 19:57:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1891004 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=HwfpJ14b; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4TLWp90h9Qz23dy for ; Fri, 26 Jan 2024 06:57:53 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F26D33858D38 for ; Thu, 25 Jan 2024 19:57:50 +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 D1C213858D38 for ; Thu, 25 Jan 2024 19:57:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D1C213858D38 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 D1C213858D38 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=1706212649; cv=none; b=NTq0XTno5oRB9Q8UrKSFMBGwJVeyP2ev2grr3uJXcQkAgDYvSaEVh8kzPL5Y7fgv6lkH3vsyqDOPvoRZUNnUv2EF99k1qHqSQk1PDM2Cfs3o5mMy6YEGmvuZs+ujCRGfFB3BBbKqD7p1XtqNQf8QDS5L3YWKBgw5OQ/L2Ck/SMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706212649; c=relaxed/simple; bh=XSrEYC363OBYWDWy3dvJL3v0pL+lIThW67JiUbI0wcI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Ftvo3itrP66/jhQw5iun1stHzQ3P15O21v/IesO9N5XkWwUfPKpyLKsGE8nQIRbQ3ShCNeMJPsUXuCYrnNvxKI9GqS71N+Tv4jOsiuNYLB4wfFo1EPjvbPhocsFPa7xCER0NNPHfJCNJ9hXZu/JA9ezzKPQpruLVIEOZKl0cUFM= 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.24/8.17.1.24) with ESMTP id 40PHgQcj007555 for ; Thu, 25 Jan 2024 19:57:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=zjhpPth bhu919UEToGC3fhpn2ZsS8IrcsTrFFQB3N/c=; b=HwfpJ14bUcIsUsaGcetEtAC foY2ApCen7G8jFs0a/AJ+xyANtZxOdwz9Bmk6kQVdewaPKVNHhlLs5fwAqwcvDa6 DqJvUtB6i8wY/sUO18gmz8APkAdObr6hyG1NMWh3SYyBmvpebpUViduF3m6xg55Y 91pB9V+c9OpIACN/hDceSFUKwaR1UMv2OuiW47TjSd/RPz+UY13f7njfz9gLlQrX L/M4SNKb7Cy2BPZMvg5C9b2Q5Jj8OCASnaAenh7GkZmL0lFLUzhnivfMGG4lqczB ipERuo4xdpqfTUWvdt0ItKzGIkd3vpv6dMdAec5shJE067dOiVTrzk5FwFUXJUQ= = Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vufk9abxa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jan 2024 19:57:23 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40PJvN8g024877 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jan 2024 19:57:23 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; Thu, 25 Jan 2024 11:57:22 -0800 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] aarch64: Fix undefinedness while testing the J constraint [PR100204] Date: Thu, 25 Jan 2024 11:57:12 -0800 Message-ID: <20240125195712.410550-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-GUID: yT8e8jNoGQabuy5TvYoIMJ_9mQEHJXns X-Proofpoint-ORIG-GUID: yT8e8jNoGQabuy5TvYoIMJ_9mQEHJXns 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-01-25_12,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401250143 X-Spam-Status: No, score=-13.3 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+incoming=patchwork.ozlabs.org@gcc.gnu.org The J constraint can invoke undefined behavior due to it taking the negative of the ival if ival was HWI_MIN. The fix is simple as casting to `unsigned HOST_WIDE_INT` before doing the negative of it. This does that. Committed as obvious after build/test for aarch64-linux-gnu. gcc/ChangeLog: PR target/100204 * config/aarch64/constraints.md (J): Cast to `unsigned HOST_WIDE_INT` before taking the negative of it. Signed-off-by: Andrew Pinski --- gcc/config/aarch64/constraints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md index 8566befd727..a2569cea510 100644 --- a/gcc/config/aarch64/constraints.md +++ b/gcc/config/aarch64/constraints.md @@ -118,7 +118,7 @@ (define_constraint "Uat" (define_constraint "J" "A constant that can be used with a SUB operation (once negated)." (and (match_code "const_int") - (match_test "aarch64_uimm12_shift (-ival)"))) + (match_test "aarch64_uimm12_shift (- (unsigned HOST_WIDE_INT) ival)"))) ;; We can't use the mode of a CONST_INT to determine the context in ;; which it is being used, so we must have a separate constraint for