From patchwork Tue Aug 13 04:30:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1971731 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=alfPMFy9; 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 4Wjdk53NjXz1yXl for ; Tue, 13 Aug 2024 14:31:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 16026385700F for ; Tue, 13 Aug 2024 04:31:06 +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 725433858D34 for ; Tue, 13 Aug 2024 04:30:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 725433858D34 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 725433858D34 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=1723523440; cv=none; b=NJ9eRYxi3S/rqjEeO8ThiRxWcXKYo8opbHMjx4PR2d284QOwfUkHwsSMEoY6aeyMJdy8qdFJ95U8vjYt2H2d7yF2C2qaz2RTl+8lFlBdlscG7LEXWaWeB3gipHGge2wE4lG7Zq/hMv4IE/uz8Bb3OrxD57GNar/2xQ0IY3lL8iI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723523440; c=relaxed/simple; bh=hXx85HxbDzEqhBLWO+abWH7vXDufJN0Rt9p0XMYyK7o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jX+4t6fI03cicFg8hhQONVq7FPq2Q7+YsPL7Vhpn9r9tbpEGzCUTOLCps/AWlnC4Ma5Y2Jqy03RwehadcggzQ3sgi1zSZaCmN3q0IY0u04LQVZTBGLvOLq0Wzj9w+Ked2o3G5ihV7tcI/7ALyhIeo7B0PmtkGGQkqWShGWC+ZRg= 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.18.1.2/8.18.1.2) with ESMTP id 47CDSWpN015965 for ; Tue, 13 Aug 2024 04:30:36 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=HC97DzakIFwloR1CJgJMoe +J5FsSSHVqH0T0V1/yOXI=; b=alfPMFy9bI4TSYcjUcqt+gqNClNEC/tIw/hazG zOgdQCswNF8Pfpfc2X5rBiwisqiXg7T3wEJCrAL7DddDVGvbw0hCMBmmxghguDBV EHdO7UHqXhq1NW7KGaBEULckZtgZOdrYhSFA168Mjyx9aIzFtud0Qp0QQBp7M+HD AJacTWlL6ExD5r2IH1e2u9gGIGGjkXzUj4NAYP1tct2VDLDwTR1N9Vhu7I4rEg8A a4dIZwPeehZoN36B5VufztHGwlLtSjI6o797Zm9fsPixqhAEeU6bQaqLG94FENgK wvDQICd6mSXmfVNJz9ywIPBvEzpBgRs1cnD+lBLuz00JDo4w== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 40x1chp5dp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 13 Aug 2024 04:30:35 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 47D4UZgU027135 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 13 Aug 2024 04:30:35 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, 12 Aug 2024 21:30:34 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH 1/3] testsuite: Add testcases for part of PR 103660 Date: Mon, 12 Aug 2024 21:30:21 -0700 Message-ID: <20240813043023.3685386-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-GUID: P8OqB2UxDXtLs6fPnBoRyrKhRWWnHKiT X-Proofpoint-ORIG-GUID: P8OqB2UxDXtLs6fPnBoRyrKhRWWnHKiT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-12_12,2024-08-12_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 bulkscore=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 suspectscore=0 mlxlogscore=949 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408130030 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, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_NONE, 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 IOR part of the bug report was fixed by r13-4620-g4d9db4bdd458 but that added only aarch64 specific testcases. This adds 4 generic testcases for this to check to make sure they are optimized. The C++ testcases are the vector type versions. PR tree-optimization/103660 gcc/testsuite/ChangeLog: * g++.dg/tree-ssa/pr103660-0.C: New test. * g++.dg/tree-ssa/pr103660-1.C: New test. * gcc.dg/tree-ssa/pr103660-0.c: New test. * gcc.dg/tree-ssa/pr103660-1.c: New test. Signed-off-by: Andrew Pinski --- gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C | 28 ++++++++++++++ gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C | 28 ++++++++++++++ gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c | 33 +++++++++++++++++ gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c | 43 ++++++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C b/gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C new file mode 100644 index 00000000000..766ec92457c --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr103660-0.C @@ -0,0 +1,28 @@ +/* PR tree-optimization/103660 */ +/* Vector type version. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-forwprop1-raw -Wno-psabi" } */ + +typedef int v4si __attribute((__vector_size__(4 * sizeof(int)))); +#define funcs(OP,n) \ +v4si min_##n(v4si a, v4si b) { \ + v4si X = -(a < b) * a; \ + v4si Y = -(a >= b) * b; \ + return (X OP Y); \ +} \ +v4si f_##n(v4si a, v4si b, \ + v4si c, v4si d) { \ + v4si X = -(a < b) * c; \ + v4si Y = -(a >= b) * d; \ + return (X OP Y); \ +} + + +funcs(|, ior) + +/* min_ior should produce min or `a < b ? a : b` depending on if the target + supports min on the vector type or not. */ +/* f_ior should produce (a < b) ? c : d */ +/* { dg-final { scan-tree-dump-not "bit_ior_expr, " "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times "(?:lt_expr|min_expr), " 2 "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times "(?:vec_cond_expr|min_expr), " 2 "forwprop1" } } */ diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C b/gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C new file mode 100644 index 00000000000..713057586f2 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr103660-1.C @@ -0,0 +1,28 @@ +/* PR tree-optimization/103660 */ +/* Vector type version. */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-forwprop1-raw -Wno-psabi" } */ + +typedef int v4si __attribute((__vector_size__(4 * sizeof(int)))); +#define funcs(OP,n) \ +v4si min_##n(v4si a, v4si b) { \ + v4si X = a < b ? a : 0; \ + v4si Y = a >= b ? b : 0; \ + return (X OP Y); \ +} \ +v4si f_##n(v4si a, v4si b, \ + v4si c, v4si d) { \ + v4si X = a < b ? c : 0; \ + v4si Y = a >= b ? d : 0; \ + return (X OP Y); \ +} + + +funcs(|, ior) + +/* min_ior should produce min or `a < b ? a : b` depending on if the target + supports min on the vector type or not. */ +/* f_ior should produce (a < b) ? c : d */ +/* { dg-final { scan-tree-dump-not "bit_ior_expr, " "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times "(?:lt_expr|min_expr), " 2 "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times "(?:vec_cond_expr|min_expr), " 2 "forwprop1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c b/gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c new file mode 100644 index 00000000000..6be0721aedd --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr103660-0.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/103660 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-forwprop4-raw" } */ + +#define funcs(OP,n) \ +int min_##n(int a, int b) { \ + int t; \ + int t1; \ + int t2; \ + t1 = (a < b) * a; \ + t2 = (a >= b) * b; \ + t = t1 OP t2; \ + return t; \ +} \ +int f_##n(int a, int b, int c, \ + int d) { \ + int t; \ + int t1; \ + int t2; \ + t1 = (a < b) * c; \ + t2 = (a >= b) * d; \ + t = t1 OP t2; \ + return t; \ +} + +funcs(|, ior) + +/* min_ior should produce min */ +/* f_ior should produce (a < b) ? c : d */ +/* { dg-final { scan-tree-dump-not "bit_ior_expr, " "forwprop4" } } */ +/* { dg-final { scan-tree-dump-times "min_expr, " 1 "forwprop4" } } */ +/* { dg-final { scan-tree-dump-times "lt_expr, " 1 "forwprop4" } } */ +/* { dg-final { scan-tree-dump-times "cond_expr, " 1 "forwprop4" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c new file mode 100644 index 00000000000..f3c207cf6c4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr103660-1.c @@ -0,0 +1,43 @@ +/* PR tree-optimization/103660 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fgimple -fdump-tree-forwprop4-raw" } */ + +#define funcs(OP,n) \ +__GIMPLE() \ +int min_##n(int a, int b) { \ + _Bool X; \ + _Bool Y; \ + int t; \ + int t1; \ + int t2; \ + X = a < b; \ + Y = a >= b; \ + t1 = X ? a : 0; \ + t2 = Y ? b : 0; \ + t = t1 OP t2; \ + return t; \ +} \ +__GIMPLE() \ +int f_##n(int a, int b, int c, \ + int d) { \ + _Bool X; \ + _Bool Y; \ + int t; \ + int t1; \ + int t2; \ + X = a < b; \ + Y = a >= b; \ + t1 = X ? c : 0; \ + t2 = Y ? d : 0; \ + t = t1 OP t2; \ + return t; \ +} + +funcs(|, ior) + +/* min_ior should produce min */ +/* f_ior should produce (a < b) ? c : d */ +/* { dg-final { scan-tree-dump-not "bit_ior_expr, " "forwprop4" } } */ +/* { dg-final { scan-tree-dump-times "min_expr, " 1 "forwprop4" } } */ +/* { dg-final { scan-tree-dump-times "lt_expr, " 1 "forwprop4" } } */ +/* { dg-final { scan-tree-dump-times "cond_expr, " 1 "forwprop4" } } */