From patchwork Mon Feb 19 21:33:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1901140 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=gpuR+oev; 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 4Tdwlg4mYMz1yP6 for ; Tue, 20 Feb 2024 08:34:06 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 37DEE3858C66 for ; Mon, 19 Feb 2024 21:34:04 +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 583B13858D20 for ; Mon, 19 Feb 2024 21:33:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 583B13858D20 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 583B13858D20 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=1708378426; cv=none; b=dlcxttQzOkAEWz9tY8RRS+eeHmI/aN7x91Lk5rC0JoegDSIS/+8BF0VlAM/e8pHL2UbjKKTPCZoZyxmgeBWfD6hVKNyAdlKrO3AOSOHoRh/GDS0ngwZX3BlfrYAvX2m/XUYkx75UzTUifLzKAnuzf5v6Tt9UWFVmwu4vK3FFloc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708378426; c=relaxed/simple; bh=MwmA94ekI0ZbxBc7kvDr6hv0WDREp3QGArgGPrBDZ2Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GUJT3fgAdtKeSUh8nL55LvutwGt2j28HdClfpWx5EtGV2q9/xqNR0qqdQ3fLjzs3GjlwQ6G9Q2qBftdXQhsRCQhqMDLobpBAdlATuSDXDRPf4ENwtjXgjzQ/EieN/k32bIzKeJQUP0z9VuIZpCmnymw1YeAjKDncc8VP4DTLjv4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41JLSW13006735 for ; Mon, 19 Feb 2024 21:33:44 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=U3gRuOr Y0wl+yiztXgoFzRIIgeQ8CCdq3xo884+Rutc=; b=gpuR+oevE1itmN48CU4FHA8 7YaL4UbPaGJGZt63V/dJJtumFdZzEQHxrYvLWn7F4dFLob8k9aE6xOQaWt5ZuHN9 Mds21A1yp9KXIDGvTh4gtfZMe5D4TBCQ6ssAnAs9XXzO0ntlDBG7u/h73ZhF5rD9 nzac6i7XNMtJKpuSNkjNWC7/uoMCLL3RBXKEF6gwLGg8mKgo95PPrTvgvXLpTKeD 5lI873tAFRimCiuZpbpyhbZgU1NxbZ4c0HLlyjiNfD1G2fKHBbba10elByh55aS0 ke/swdX227xCqZjBHLYBXeBKERmAwYnyt/ibhHwjIZhosQiFPuaYZzzGYudWidg= = Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wc6te92j2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 19 Feb 2024 21:33:44 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41JLXhWd025548 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 19 Feb 2024 21:33:43 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, 19 Feb 2024 13:33:43 -0800 From: Andrew Pinski To: CC: Andrew Pinski Subject: [Committed] analyzer: Fix maybe_undo_optimize_bit_field_compare vs non-scalar types [PR113983] Date: Mon, 19 Feb 2024 13:33:33 -0800 Message-ID: <20240219213333.90226-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: nalasex01c.na.qualcomm.com (10.47.97.35) 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: 93ecRSvAzqRecSozIgvvWDe5a7kF6Zgm X-Proofpoint-ORIG-GUID: 93ecRSvAzqRecSozIgvvWDe5a7kF6Zgm 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-02-19_20,2024-02-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 impostorscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=0 clxscore=1015 spamscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 mlxlogscore=879 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402190161 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, 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 After r14-6419-g4eaaf7f5a378e8, maybe_undo_optimize_bit_field_compare would ICE on vector CST but this function really should be checking if we had integer types so reject non-integral types early on (like it was doing for non-char type before r14-6419-g4eaaf7f5a378e8). Committed as obvious after build and tested for aarch64-linux-gnu with no regressions. PR analyzer/113983 gcc/analyzer/ChangeLog: * region-model-manager.cc (maybe_undo_optimize_bit_field_compare): Reject non integral types. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/torture/vector-extract-1.c: New test. Signed-off-by: Andrew Pinski --- gcc/analyzer/region-model-manager.cc | 3 +++ .../gcc.dg/analyzer/torture/vector-extract-1.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/analyzer/torture/vector-extract-1.c diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc index 62f808a81c2..21e13b48025 100644 --- a/gcc/analyzer/region-model-manager.cc +++ b/gcc/analyzer/region-model-manager.cc @@ -602,6 +602,9 @@ maybe_undo_optimize_bit_field_compare (tree type, tree cst, const svalue *arg1) { + if (!INTEGRAL_TYPE_P (type)) + return NULL; + const binding_map &map = compound_sval->get_map (); unsigned HOST_WIDE_INT mask = TREE_INT_CST_LOW (cst); /* If "mask" is a contiguous range of set bits, see if the diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/vector-extract-1.c b/gcc/testsuite/gcc.dg/analyzer/torture/vector-extract-1.c new file mode 100644 index 00000000000..5b878e6e4e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/torture/vector-extract-1.c @@ -0,0 +1,14 @@ +/* PR analyzer/113983 */ + +/* maybe_undo_optimize_bit_field_compare used to ICE on this + because it was not checking for only integer types. */ + +typedef int __attribute__((__vector_size__(8))) V; +int i; + +V +foo(void) +{ + V v = (V){}; + return (0, 0) * (i & v); +}