From patchwork Tue Oct 29 05:08:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 99743 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 033E43858408 for ; Tue, 29 Oct 2024 05:08:49 +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 BCB013858D26 for ; Tue, 29 Oct 2024 05:08:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BCB013858D26 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 BCB013858D26 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=1730178500; cv=none; b=VbevZeVke7ZoaHEjrTeAqYfsh9iWTXK9tHAhwjOwSZYvyceUywoO+bUAas1f2pAnDHtcz7NZx5lvrWiVgGN23R3WTE0jL2ztBins+ZNjy8Dn6GxSJRqOnX8FeTngAk1ftOFseOKUPGYD+xDolCRAEffOfinXfa+z7+4afauoEcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730178500; c=relaxed/simple; bh=UiTOXk3vF9GG7T/KJfLSbibfNNE1K/MeaxKnid1IZz4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tOfziy6ERKrAVVj2u8l61iwC3Q5e8VOJdnBjx0cdGwjronm0gSqbqib9S46yqeml0IiCReHDKNnHLySbcshqg9iaiXoJ+7x6V2oIEqsN/oTcRWtz5cEVkU5NMc7NUzNEJWSmK4LkjKRSg7aaMfKAdm3jtdNDnwb5Wx212dIE+VE= 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.18.1.2/8.18.1.2) with ESMTP id 49SKXQ5e000668 for ; Tue, 29 Oct 2024 05:08:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=/xtZOktH1guKa6cArtZp3w P5clRkO+j6vgGY96GoQbY=; b=KajY31/K/Kt5cv14G3/2JpxRu1vgl9nAYKGEjg CQk7PyvhDN+GgKVcr7HPu/SQrLyf06aeMQxDFttqW3iBVf5lYTjxt94u2rWnOryK F/QebOt3Eyu9qAq/8sWNrv2EFxpLjIQvvvjtUKfEjMa6+5InwKEBBHcnNW3FY6Sx OeWs43n78Lf5O3EHrJLFaaxjNT+Nw2ifIz5XWtQ8cQlciqBEhf4Qob2Y6kh6Estk uPtp+DCQa5UkH5/Vdkg/HmlmrUMKcwEXu4bE72gucVQgzUXGFAIcSuwg0xHPu3iJ cDx9aTzaNCI/47JRwQqg+EaeuAG+zDMRGmnhWe00SpzfcyIA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 42grt6y605-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Oct 2024 05:08:17 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49T58FuL012975 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Oct 2024 05:08:15 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.1544.9; Mon, 28 Oct 2024 22:08:15 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] testcase: Add testcase for tree-optimization/117341 Date: Mon, 28 Oct 2024 22:08:04 -0700 Message-ID: <20241029050804.896741-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: j2XEKP0bmNlciabXLS4pVhe2EoEjbBG7 X-Proofpoint-GUID: j2XEKP0bmNlciabXLS4pVhe2EoEjbBG7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 adultscore=0 clxscore=1015 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 mlxscore=0 suspectscore=0 mlxlogscore=743 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410290039 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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~patchwork=sourceware.org@gcc.gnu.org Even though PR 117341 was a duplicate of PR 116768, another testcase this time C++ does not hurt to have. The testcase is a self-contained and does not use directly libstdc++ except for operator new (it does not even call delete). Tested on x86_64-linux-gnu with it working. PR tree-optimization/117341 gcc/testsuite/ChangeLog: * g++.dg/torture/pr117341-1.C: New test. Signed-off-by: Andrew Pinski --- gcc/testsuite/g++.dg/torture/pr117341-1.C | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 gcc/testsuite/g++.dg/torture/pr117341-1.C diff --git a/gcc/testsuite/g++.dg/torture/pr117341-1.C b/gcc/testsuite/g++.dg/torture/pr117341-1.C new file mode 100644 index 00000000000..b13d2502e35 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr117341-1.C @@ -0,0 +1,54 @@ +void swap(long &a, long &b) +{ + long t = a; + a = b; + b = t; +} + +struct Array { + long arr[1]; + Array() : arr() {} + /* Operators */ + long& operator[](int index) { return arr[index]; } + const long& operator[](int index) const { return arr[index]; } + /* Operations */ + void swap(Array& array) { + for (int i = 0; i < 1; ++i) + ::swap(arr[i], array[i]); + } +}; + +class Vector : public Array {}; + +struct v +{ + Vector *e; + v() : e (new Vector[4]){} + Vector& operator[](int index) { return e[index]; } + const Vector& operator[](int index) const { return e[index]; } +}; +static inline Vector func(const Vector& y) +{ + return y; +} + +volatile int a; + +int main() { + v solution; + solution[0][0] = 1; + int t = a; + for (int i = 0; i < 3; ++i) { + const Vector& v = solution[i]; + Vector sum; + const long delta = func(v)[0] & t; + sum[0] = v[0] + delta; + solution[i + 1].swap(sum); + } + for(int i = 0; i < 4; i++) + { + if (solution[i][0] != 1) + __builtin_abort(); + } + return 0; +}