From patchwork Wed May 31 09:55:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 101308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2756374vqr; Wed, 31 May 2023 02:57:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4qc7oCosqA0Vzh/M2xFlwNHkVXNoJDaTEwovJ/XxJ1i44qpMAV0lpkcHJdLFRWTZ4GS8Nh X-Received: by 2002:aa7:ccc4:0:b0:514:994c:2982 with SMTP id y4-20020aa7ccc4000000b00514994c2982mr2981281edt.40.1685527042762; Wed, 31 May 2023 02:57:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685527042; cv=pass; d=google.com; s=arc-20160816; b=sIInfdCpF6W/K6sqFQGJbfiQopbnpvdp4efQTZgA4eBhnsgzUfuGkV7qjhiUtSc8X/ nA42PLOfXdjA7cix9RAV3SGENZ7JUz/ZbNvaAxK/g68pp5bQEI0b9vWRiCE14Va0Bnz8 k31fz5jeLxt06KyPr//dicOA2IzlbZPyvhxq5QxZPMHBJSIeeWlsoSipISX+RQC2nuTX ADT/rBWj/EatPWgVIhnBsGFEO+SaPpWukjxcniOAGDSclrfgA2+gf0fWdRGANFU7h8Uk lTdD8a1kEp8J8KoBGjrwMS4OJFWWwTVoVYl95Aou0bVmw+solavHsoWP0BQtDNadrjdX bnJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dmarc-filter:delivered-to; bh=zAw1rWPjJ1eghSwsRCjGTY8Z4j30YoEjoaL/dfgB+9Y=; b=s6ilpalLxroZotu3MS/tBdwFIQYTwC/9QwC/eFI/L4qd8psJ0V0HvGYget/lvODCRL dFDXqzc3UhddT/jQOU4v5OARouRZYTfIh7WDcPYIAfaSIBuopY2ww/t6WeyNWlrQsSR6 5neKRBZFvXW/PrwhHRrpvCqoBFl7d7/awgo1S0hIDRFSyDfrvJhUPjV0V3oK5uxtFx5i HHbD6iXF+zPDYiL+5KZlwwCGN4kpMfarC5ETBFhJ9wXWU0T3kM33uviSGm6JvaW7neJ/ gCkcM+vf6Mt6/2dRgTj2R+suGQ3hGgCX6tSwqpVr7Q9tiN9Amv5JLrX2BTddLWbd2zzb AMxQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b=AAPSEjXC; arc=pass (i=1 spf=pass spfdomain=cipunited.com dkim=pass dkdomain=cipunited.com dmarc=pass fromdomain=cipunited.com); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id q6-20020aa7da86000000b00514b0f33424si2281488eds.339.2023.05.31.02.57.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 02:57:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b=AAPSEjXC; arc=pass (i=1 spf=pass spfdomain=cipunited.com dkim=pass dkdomain=cipunited.com dmarc=pass fromdomain=cipunited.com); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2513D385589B for ; Wed, 31 May 2023 09:56:51 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2099.outbound.protection.outlook.com [40.107.215.99]) by sourceware.org (Postfix) with ESMTPS id C80A43858C1F for ; Wed, 31 May 2023 09:56:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C80A43858C1F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cipunited.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cipunited.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jHBuPgbokdwmYf5bsoWyCCHThAkdRJPoqJX95RLcJUmPVRS3wjPdSrHyEYgzCHcKH1DfAgX+QT+otVPlWH2E7PQr2uVvT1sxvSduK9Z2oeZyALMRa786haGnOlgVsRiu2knij35+QYQqwwlgHOq5yf6m2LrWVKeO37oySRjP8xsQ8mBR8FE0t//5mqlf3ISJ23co4H7egO+Yx5h2iglRGKyCrMYNCtUFkXfAKS/G8Pkfq72siQjvlNJ9SWmHxEwZdT+ni6A94AhB3fTXuyBp4ETuz5np7Z7Si0Aol1jnjD7MK+FTCm7LgcqCQORQ5icEFKrM8VCqLNdRd73dRfMWcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zAw1rWPjJ1eghSwsRCjGTY8Z4j30YoEjoaL/dfgB+9Y=; b=TsrbFWcTlb9ZTU1hVOUg6xDWYG0XknrpHeJAKQbCsGugnyebWBV0PNw1jrA10Hwc5/8U/Z31LvAxT5SMWljqTZutLTBiXV7l2AVld3kZGMv+VMEuaLVr3HwDo/qhszlDhXKp3YLUfUD6U2liq2A0DxXGPT0Z0CNsdhp2IYiTNzSSDsTc0qIP1jHW0AqPOam4m9tbSc2E4bCMS5qsTWauRsDt+IltXBfD6lXy0Kxgi6Fq0tkbzpuQXnk7lQwzwqHBslBZ28aEod/RNY5lU4C+pUyZW3nsclZ1psnE0GOT5WLzJxD/iWsCvZ05VbQWlWR6NQuaqw0ZVsh//5vjNKvZYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cipunited.com; dmarc=pass action=none header.from=cipunited.com; dkim=pass header.d=cipunited.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cipunited.onmicrosoft.com; s=selector1-cipunited-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zAw1rWPjJ1eghSwsRCjGTY8Z4j30YoEjoaL/dfgB+9Y=; b=AAPSEjXCdWYQr4Aq3lDScxEVSetuRrsW4QXPvj18fk6doOyrqnpZqbQJjsqy5SasGLe7sQ6Mr2zOA9tZ48WcU+971hcRcwJPsuqYdS29EG5J7ReJ00FCDOm1vMgWDTzToDmz1mvikw+eQrhGwOvK6EB0fJgH+VTI1XQzM1avHhY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cipunited.com; Received: from SEZPR04MB6121.apcprd04.prod.outlook.com (2603:1096:101:98::10) by PSBPR04MB3912.apcprd04.prod.outlook.com (2603:1096:301:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Wed, 31 May 2023 09:56:15 +0000 Received: from SEZPR04MB6121.apcprd04.prod.outlook.com ([fe80::fd0f:3691:40e3:9252]) by SEZPR04MB6121.apcprd04.prod.outlook.com ([fe80::fd0f:3691:40e3:9252%7]) with mapi id 15.20.6455.020; Wed, 31 May 2023 09:56:15 +0000 From: YunQiang Su To: gcc-patches@gcc.gnu.org Cc: macro@orcam.me.uk, jiaxun.yang@flygoat.com, syq@debian.org, richard.sandiford@arm.com, jeffreyalaw@gmail.com, YunQiang Su Subject: [PATCH v2 2/2] MIPS: Don't expand large unaligned block move Date: Wed, 31 May 2023 17:55:51 +0800 Message-Id: <20230531095551.1299186-2-yunqiang.su@cipunited.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230531095551.1299186-1-yunqiang.su@cipunited.com> References: <20230531095551.1299186-1-yunqiang.su@cipunited.com> X-ClientProxiedBy: SG2P153CA0041.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::10) To SEZPR04MB6121.apcprd04.prod.outlook.com (2603:1096:101:98::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR04MB6121:EE_|PSBPR04MB3912:EE_ X-MS-Office365-Filtering-Correlation-Id: f4c60016-19d3-4956-0436-08db61bd45f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YOVlewzRX4Kn9PjJhDDL8MVzbb0HgftmUGDqBlh5Wya4TmMYWSh/3Yae+oYxI229PO0h+I2YpEhnkWSKuV9B1DlkSzE6wwpOpx7pIto+hwbO2f+QVI+M/z/mxwiMiGwpKW2V+6jerc8jteoL47z1U9CXcBrFDcn1pfviQI6AqMOqTIOb4d3Y7yUK1nSYi70hHazBxkuccOEnMmXC70BGuIvFqyrBf8VpslBMBIE2KrrGOCwyqUfVv/tZrJgmxhX32skkADKTNVD+PATGQL//wp3ITJI9Ta31lmMSeYv7wQE89BCc/M4wRl1SCrQ2A79uVUb8ajiwcj/VmCgTnzARt9Ci/hTgGxUja4Xvn2fiiDf+LO2KWhp4b96RER5QfFTvbItVEH91fOcHGiSnRBOBxHFYtHSzRoDsOvRNyxz3Hvm+T2McVCMoKGG1aAV51CXg7pI260StvGS0IlvH5O4quxHQUsMwn7TMND9U4kkJsSh4hX1hIyre1a85A89KzWGCJGaPlJ8Pi6AUpoQgendTAJrgl8OM9nxRhgM5uqP/BI/0l6O+3ddzLykO2dAGetPxrVQkte6TR/vXqtW16TzdQ5sKElLJ6J21oR4BHvuyKuM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR04MB6121.apcprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(366004)(39830400003)(346002)(136003)(376002)(396003)(451199021)(6506007)(6512007)(1076003)(26005)(107886003)(66946007)(66476007)(66556008)(6916009)(38350700002)(38100700002)(5660300002)(4326008)(36756003)(8676002)(8936002)(86362001)(83380400001)(41300700001)(316002)(52116002)(6666004)(6486002)(186003)(2906002)(478600001)(84970400001)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5I9u1hlioTrfSgm0t07V0xtDHkdSM0xVzz2KrkxrQCEMREKUYTNLNTHe7eZ+sWbDyS3J5U8So6reE7xaCcBTqBYLrWZCwQ/NxWzvZ5twPIrb869Mrd+ZoPG8CQVlCq++bRtq3dwb/Stjoco+Qi0K15VNWBb4eBFTq6vwcBauqgNcXBEEDXi1tZhin8/r8ik3ton2uGejrd+VBE0xntu7LSt6TQjIfkcD844JpBp/0Un29asJuu9nN9aj+bTcJXN3hq4ecmbh1uwwdMcchztdAz0Yn/ojwXxB7QW2mx3fcUumz5sgueCc3308BdZdKqEITGeDI6EzVoO55MKsFj5OVLDqt2ly+MytFRkBZsyspLN8g40kiNh8rouvvbaHhQYGCigGfW12bDNZ5T5ZfaQOuolKtYV64RSmqbRamhcUrdTNtPiBbxEfCS0rk1aVkEqeIDFU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wmSCjIDYvylv7LQcSQ6mZWRV7Lgikd9H/34APoA0R58iQF64a/y09FZ+iUs86VCZoeRlZYDJClEkJy0nwyP/w== X-OriginatorOrg: cipunited.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4c60016-19d3-4956-0436-08db61bd45f2 X-MS-Exchange-CrossTenant-AuthSource: SEZPR04MB6121.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2023 09:56:15.6126 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e31cf5b5-ee69-4d5f-9c69-edeeda2458c0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8pCME5gAYvzx5xuq78iP8t2AmXJSVEpaNrwlXBtHTwJ1sLJfW+zCmR0d4ZKpPxa7zm8NbYWcjuB1zRcxeAl0CUqV1qDNSOPZr+6Jqmkrvtg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSBPR04MB3912 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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.29 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767403204648786269?= X-GMAIL-MSGID: =?utf-8?q?1767403204648786269?= For large unaligned block move, lib call may have better performance than expanding. Let's just return, if length is larger than 64 on O32 larger than 128 on N32/N64. Here are some test results: CPU Aligned O32 N32 N64 Cavium 7130 1 72 192 192 Cavium 7130 2 96 192 192 Cavium 7130 4 +inf 192 192 Cavium 7130 8 +inf +inf +inf LS3A 2000 1 32 32 64 LS3A 2000 2 32 64 64 LS3A 2000 4 +inf 32 48 LS3A 2000 8 +inf +inf +inf LS3A 4000 1 32 64 128 LS3A 4000 2 64 64 128 LS3A 4000 4 192 128 192 LS3A 4000 8 192 +inf +inf Ingenic X2000 1 96 - - Ingenic X2000 2 96 - - Ingenic X2000 4 +inf - - interAptiv 1 64 - - interAptiv 2 64 - - interAptiv 4 +inf - - P6600 1 64 128 128 P6600 2 64 128 128 P6600 4 256 192 128 P6600 8 +inf +inf +inf P6600 1U 48 48 48 -mno-unaligned-access P6600 2U 128 96 96 -mno-unaligned-access P6600 4U 384 768 768 -mno-unaligned-access P6600 8U 1024 +inf +inf -mno-unaligned-access I6500 1 384 896 640 I6500 2 256 768 512 I6500 4 384 704 512 I6500 8 512 1024 1024 I6500 1U 32 32 32 -mno-unaligned-access I6500 2U 96 64 64 -mno-unaligned-access I6500 4U 384 640 768 -mno-unaligned-access I6500 8U 256 +inf +inf -mno-unaligned-access When the length of block move is larger than this value, (g)libc call has better performance. gcc/ * config/mips/mips.cc (mips_expand_block_move): don't expand large unaligned block move. gcc/testsuite/ * gcc.target/mips/expand-block-move-large.c: new test. --- gcc/config/mips/mips.cc | 6 +++++ .../gcc.target/mips/expand-block-move-large.c | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/gcc.target/mips/expand-block-move-large.c diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc index ca297e3c1e5..7a7f4be627f 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -8308,6 +8308,12 @@ mips_expand_block_move (rtx dest, rtx src, rtx length) || MEM_ALIGN (dest) < MIPS_MIN_MOVE_MEM_ALIGN)) return false; + if ((ISA_HAS_LWL_LWR || ISA_HAS_UNALIGNED_ACCESS) + && INTVAL (length) > MIPS_MAX_MOVE_BYTES_STRAIGHT * 2 + && MEM_ALIGN (src) < BITS_PER_WORD + && MEM_ALIGN (dest) < BITS_PER_WORD) + return false; + if (INTVAL (length) <= MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER) { mips_block_move_straight (dest, src, INTVAL (length)); diff --git a/gcc/testsuite/gcc.target/mips/expand-block-move-large.c b/gcc/testsuite/gcc.target/mips/expand-block-move-large.c new file mode 100644 index 00000000000..98705f6c560 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/expand-block-move-large.c @@ -0,0 +1,22 @@ +/* { dg-final { scan-assembler "memcpy" } } */ +/* { dg-final { scan-assembler-not "lwl" } } */ +/* { dg-final { scan-assembler-not "swl" } } */ +/* { dg-final { scan-assembler-not "lwr" } } */ +/* { dg-final { scan-assembler-not "swr" } } */ +/* { dg-final { scan-assembler-not "ldl" } } */ +/* { dg-final { scan-assembler-not "sdl" } } */ +/* { dg-final { scan-assembler-not "ldr" } } */ +/* { dg-final { scan-assembler-not "sdr" } } */ + +char a[4097], b[4097]; +#ifdef __mips64 +#define MAX_SIZE 128 +#else +#define MAX_SIZE 64 +#endif + +NOCOMPRESSION void +foo () +{ + __builtin_memcpy(&a[1], &b[1], MAX_SIZE + 16); +}