From patchwork Thu Jan 11 10:32:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andrew Pinski (QUIC)" X-Patchwork-Id: 187284 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1354879dyi; Thu, 11 Jan 2024 02:34:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUObsNCkOTY4Tccu7y9s4J2ljb5kQIeejDfkr1FB43PlKGL0vqj5vYb0VY5FJ+Dt1YFVTn X-Received: by 2002:a05:620a:298a:b0:783:1e4c:b5dc with SMTP id r10-20020a05620a298a00b007831e4cb5dcmr1246284qkp.7.1704969257507; Thu, 11 Jan 2024 02:34:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704969257; cv=pass; d=google.com; s=arc-20160816; b=SHCLdgT4jS2Lce/OdqxDx6GFSC+YR9Yv8wV3EPYhjRoto4Nvh35BGJnJ5yoDPiwaan k7FoSUxllLzq3R+7jj2KEd9DUw6cnzNQ/PofdMf8+mzRx6fv4zFBESpgMl1tM1EPCi28 R3sbpCbxfrqTxC/WpjKWGJypaNxPAyicVb5wlYPz7DsUVXgWkuXzUM7kBQssdxx3gyNA 8pbpjO/qdZ1QUVmJmtbJvfPmn0napResyxBsE7TWbW2wTzj1i0mz7NWVuXMu9rJa/ZJi 7g3jCLMyLgEO0Yej2HPGo7nqVuBAkL/WJpw+ctB83IQlqGd8fmcuAHxZ21REaMlU9kCT Stqw== 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:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=wJi6NrLehew/tYGg0P988Kde9ydnTxTTh10s85ErVsE=; fh=o3CEdS3yGN/eIa89Zn0Kf01WYLxTE9IjKuSQGVPeOHI=; b=susjHSYStdU7xv3DDULnOFVUR6WuZSmvKj5cJxzJlEtdUxNdMim0qeI43a8Va5O8CY KvKXvAlVRCp2enlqm8T9vqfpavkSnpaabIDJeJIzKU31SQArRoEPYT959b9ONXQfdOtk PVrv71oP0M42z7zWpRG5puQ6ARwzZO7D5uTkSzvo11f3VMjHScUSW3hlAQhSAn76ynx5 R5uonZLxJ7tI1GnDrz7fcPaZozWa/AUPUCH6kGbhq1ZIuAfsT0KPq4w7Y33ay9IVs1ho DgWz9lG4AZxvdwWThmzMv9fQ0DoknO+hhZbFupOqd8SjOpSTRYcYY7FJO2EJnHas9Ao0 57mA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=kRScwm8e; 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 b15-20020a05620a088f00b007833ac2b003si617604qka.378.2024.01.11.02.34.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:34:17 -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=kRScwm8e; 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 2FCE23857B97 for ; Thu, 11 Jan 2024 10:34:17 +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 4D0583858C54 for ; Thu, 11 Jan 2024 10:33:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4D0583858C54 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 4D0583858C54 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=1704969208; cv=none; b=nILbyNr3cyvy8PQA6Dtw386iHRFy1a4TnfVqcNLXVDbzFW9VGEqQMmn2MIzato0cgZV47DumaHz9KQB1TIPgueL/8Il8+pySxZdZkE67ltSzbkNpt5LtARawbVTTpNcZJaGKFjpfJrT29fzlth56qCxs0EgQAKJqtJBBxE4RTCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704969208; c=relaxed/simple; bh=kRePhTmM1O8EfT72s4cFbE5d0GW7HWQeYgGOgBF+reo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Tk9H/GiQeTB19/apLkmAZQoPLQT0NpNb28WmDAL/R3oYBptEY59SBsPB5+JUSNw5VuRU8rc0p95MoGCDtG4Qq3ZmpJ4PY9H/xhYIpzFtgjwkgpDHE4X2OzXVKYOjq+gbpb8zYDNzDca79aSyx2GILNb3zJsCDkVUsUlk+uzJMq8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40B9EmtC001998 for ; Thu, 11 Jan 2024 10:33:25 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=wJi6NrL ehew/tYGg0P988Kde9ydnTxTTh10s85ErVsE=; b=kRScwm8eCbbcAddbkqYVvVa XP62Umni/he6k8eIXMR/AYj99z4hDWqqgum4xcVXEYSUiGqTQ0jpXt/J6qdzC4fY kBzShc6SGdxLBSzxnrpHTsU0/a15UH7gPiknaVlkwZ1ZwAGhOEvCKBz0amwXcTpR kaitQBJdsqR+IjtgUd4dgzzPnsynWOh96XfxAb+WwIgw6H+wkvaoOBjMIm9ssOLy 27aptNvjxe1hXM4AmqT5fSeB6GT9i09lKv2Rsk/gBwqo1PUDndxQEUI2IB5mROqt QgmpGHmY4jtOUH7Qr2KXelS8MLaZDWwcIB8ZLZP9l2EzVl5wuL3Ia9Yh4lP9vrA= = Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vj6c8h3f3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 Jan 2024 10:33:25 +0000 (GMT) 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 40BAXOx0002190 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 Jan 2024 10:33:24 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, 11 Jan 2024 02:33:24 -0800 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] expr: Limit the store flag optimization for single bit to non-vectors [PR113322] Date: Thu, 11 Jan 2024 02:32:17 -0800 Message-ID: <20240111103217.1306207-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: PCQwiMR_nG-EPjEovfnaDVLzD_FMFDkO X-Proofpoint-GUID: PCQwiMR_nG-EPjEovfnaDVLzD_FMFDkO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 clxscore=1015 mlxlogscore=915 adultscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 suspectscore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401110085 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: 1787789844266257634 X-GMAIL-MSGID: 1787789844266257634 The problem here is after the recent vectorizer improvements, we end up with a comparison against a vector bool 0 which then tries expand_single_bit_test which is not expecting vector comparisons at all. The IR was: vector(4) mask_patt_5.13; _Bool _12; mask_patt_5.13_44 = vect_perm_even_41 != { 0.0, 1.0e+0, 2.0e+0, 3.0e+0 }; _12 = mask_patt_5.13_44 == { 0, 0, 0, 0 }; and we tried to call expand_single_bit_test for the last comparison. Rejecting the vector comparison is needed. Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR middle-end/113322 gcc/ChangeLog: * expr.cc (do_store_flag): Don't try single bit tests with comparison on vector types. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/pr113322-1.c: New test. Signed-off-by: Andrew Pinski --- gcc/expr.cc | 2 ++ gcc/testsuite/gcc.c-torture/compile/pr113322-1.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr113322-1.c diff --git a/gcc/expr.cc b/gcc/expr.cc index dc816bc20fa..ae32fdda02b 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -13619,6 +13619,8 @@ do_store_flag (sepops ops, rtx target, machine_mode mode) if ((code == NE || code == EQ) && (integer_zerop (arg1) || integer_pow2p (arg1)) + /* vector types are not handled here. */ + && TREE_CODE (TREE_TYPE (arg1)) != VECTOR_TYPE && (TYPE_PRECISION (ops->type) != 1 || TYPE_UNSIGNED (ops->type))) { tree narg0 = arg0; diff --git a/gcc/testsuite/gcc.c-torture/compile/pr113322-1.c b/gcc/testsuite/gcc.c-torture/compile/pr113322-1.c new file mode 100644 index 00000000000..efed9603dfd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr113322-1.c @@ -0,0 +1,14 @@ +/* { dg-additional-options "-march=sapphirerapids" { target x86_64*-*-* i?86-*-* } } */ +/* PR middle-end/113322 */ + +float a[16]; +void +foo () +{ +int i; +for (i = 0; i < 16/2; i++) + { + if (a[2*i+((0 +1)%2)] != (3 * (2*i+((0 +1)%2)) + 2)) + __builtin_abort (); + } +}