From patchwork Tue Oct 29 19:15:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 99789 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 D8FF53858430 for ; Tue, 29 Oct 2024 19:16:35 +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 7FCF33858C98 for ; Tue, 29 Oct 2024 19:16:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FCF33858C98 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 7FCF33858C98 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=1730229367; cv=none; b=BR1HooawwefM7osfwaBJbzvS8fo4kfYmHyFz9e1CkgXsO5cYdRizNUVQo+wFcxURUim6wQYSjPz90mx0m17nBc+FJHedgoWekiLd4yj9as1o1a1bGTw4a3OGrMP3/vRHPAWuFHGUfX61TTGOKNfHGN7e9Jd9h5NvYwoGUBwe3Ms= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730229367; c=relaxed/simple; bh=f18kOu7bPIFedKpssyXKg0jvg4fc7vtWmNI3O8K0I2w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=eQSbDSJcKdQOMpeo37mijXbMNuP+y2ZgoBuULpNchj1Tsc20lz1smy3eriqW4sBQn1Hq6B7Pn57Bz9lKzg2sVKI3zL/ULLT/WKgwZtGkwFu1NUMR4pIdobT3GTDCleDnJ9Bkbg/0q+qYvpGI3jx4II4FdpsZakrupDkc7zLVtSk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49TEeb8A027398 for ; Tue, 29 Oct 2024 19:16:02 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=W9LzDl7AJhEs7hwVSna3LY 1hFHMQJppM9gB+dWC0dzw=; b=ICvLYDussGu4Lkp/IaDKgVB8hyrkyg21Ysp+bf 7aGKC6Jeo7y4qK4ev1qtFdibyzUHuJ8oiHcu2CgmY2lakd1e8xtp6OGS+Jl4ekxh gpYUAxTHlcw43FCeGJtQsJrjFSRsagJ7smsRKFSKuzetiULMBhfV9IwjTE1SsyUA NhQONN6FQq4JB9RcVPiX43IQ5VVDFvLwWWJnBZHnhYLxLA/s8MTz9MDdcX5fyfhu /QOcn7Wl/xJedwvA6p44wQh7jo3XbIDbqWJSOEYkm0K/Hv5OVTsEaS5ZbXX70tm4 kZhcMe5MyGTdWjduUZx37xwIEv0OJ/3YlkmUh5bR57jU90Ng== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 42k1p30tca-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Oct 2024 19:16:01 +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 49TJG0tI015751 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 Oct 2024 19:16:00 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; Tue, 29 Oct 2024 12:16:00 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] aarch64: Use canonicalize_comparison in ccmp expansion [PR117346] Date: Tue, 29 Oct 2024 12:15:49 -0700 Message-ID: <20241029191549.1217135-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: 6a8b4G2kcTgGT-fa68I-czZILEqdR3-d X-Proofpoint-ORIG-GUID: 6a8b4G2kcTgGT-fa68I-czZILEqdR3-d 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 priorityscore=1501 adultscore=0 spamscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 phishscore=0 clxscore=1015 impostorscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410290145 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 While testing the patch for PR 85605 on aarch64, it was noticed that imm_choice_comparison.c test failed. This was because canonicalize_comparison was not being called in the ccmp case. This can be noticed without the patch for PR 85605 as evidence of the new testcase. Bootstrapped and tested on aarch64-linux-gnu. PR target/117346 gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_gen_ccmp_first): Call canonicalize_comparison before figuring out the cmp_mode/cc_mode. (aarch64_gen_ccmp_next): Likewise. gcc/testsuite/ChangeLog: * gcc.target/aarch64/imm_choice_comparison-1.c: New test. Signed-off-by: Andrew Pinski --- gcc/config/aarch64/aarch64.cc | 6 +++ .../aarch64/imm_choice_comparison-1.c | 42 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/imm_choice_comparison-1.c diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index a6cc00e74ab..cbb7ef13315 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -27353,6 +27353,9 @@ aarch64_gen_ccmp_first (rtx_insn **prep_seq, rtx_insn **gen_seq, if (op_mode == VOIDmode) op_mode = GET_MODE (op1); + if (CONST_SCALAR_INT_P (op1)) + canonicalize_comparison (op_mode, &code, &op1); + switch (op_mode) { case E_QImode: @@ -27429,6 +27432,9 @@ aarch64_gen_ccmp_next (rtx_insn **prep_seq, rtx_insn **gen_seq, rtx prev, if (op_mode == VOIDmode) op_mode = GET_MODE (op1); + if (CONST_SCALAR_INT_P (op1)) + canonicalize_comparison (op_mode, &cmp_code, &op1); + switch (op_mode) { case E_QImode: diff --git a/gcc/testsuite/gcc.target/aarch64/imm_choice_comparison-1.c b/gcc/testsuite/gcc.target/aarch64/imm_choice_comparison-1.c new file mode 100644 index 00000000000..2afebe1a349 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/imm_choice_comparison-1.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* PR target/117346 */ +/* Make sure going through ccmp uses similar to non ccmp-case. */ +/* This is similar to imm_choice_comparison.c's check except to force + the use of ccmp by reording the comparison and putting the cast before. */ + +/* +** check: +** ... +** mov w[0-9]+, -16777217 +** ... +*/ + +int +check (int x, int y) +{ + unsigned xu = x; + if (xu > 0xfefffffe && x > y) + return 100; + + return x; +} + +/* +** check1: +** ... +** mov w[0-9]+, -16777217 +** ... +*/ + +int +check1 (int x, int y) +{ + unsigned xu = x; + if (x > y && xu > 0xfefffffe) + return 100; + + return x; +}