From patchwork Fri May 19 06:11:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 96203 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1017199vqo; Thu, 18 May 2023 23:12:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ct86MvFCDLmNXtT+XCcjKnD7tn4VExIyYCGOKwaByW71NHwvKcNq7xWvmO8qbpqeMQ30L X-Received: by 2002:aa7:cfd4:0:b0:510:d075:9e13 with SMTP id r20-20020aa7cfd4000000b00510d0759e13mr597966edy.22.1684476768069; Thu, 18 May 2023 23:12:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684476768; cv=pass; d=google.com; s=arc-20160816; b=05+iR4Y4NddlHDtpYrVsDHs3d4N88c1aFt0vBKpgGbRWZOkZQq4fN4J1oHcKhLPvac 7iTw3CkGZ1NslsPOykymSXyjCkr5gP1EnMQzA7bEUm97dp0Jj9C09Z/TgZ2JkotJUJNz WLl3VzLrYkAflFqZFFBpTgGOpXtliRuUlhd8KedNTfWyFwpotvWagbBDLJLyfcJeYeX0 q6ezdlN/eKiJah6KKq71qrG+1q1JGPggVtNjnCdlA3rXlyxBki1NiFD+K9tv2o+rHM9E JZ7LD7u5ng06fwI4DEwx5S3J+/IfC3KSQnxvyZOp+hBbvSIUiE9ONqsJDShuZtzDUiVc pYxA== 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:message-id:date:subject:cc:to:from :dkim-signature:dmarc-filter:delivered-to; bh=h2i1gW4bBz3hupPkfbQy717+iwva1ROxmSqOweRVKMw=; b=ybHOYsZgfbVSJ4bZ0pb6yHIeO1b2u98uBQ+tgOkLn5flVc92SIBiQXqmWC5y3Rcxx1 T375jdxOPaHS8l+YZQ+MzWnrudvG08wQYpAFkY80l4pw2nmhtN8bASR1YbvFVMKUrdBZ 70NFBRUOokXCRgLXAwlNGKLJVxff3uC+i1jLW+DGX7gVckyfdCfvUebhneqVyr3LBfWc 2yMoyFwHo8txlo5Tc2iEGevO6S6pD/wMhgBrzHDGzeiBGomNsobn3ekxGF8rZEVvQWE2 PgvtlqjRY4VO6wn+rqJIDOHww23rNlIb5egDyQsCQuLtEtLqQkcu7YfiYn6s50vU6G7a XCBg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b=KfE9dGv7; 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 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id q11-20020a056402032b00b005084808b61esi2153193edw.600.2023.05.18.23.12.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 23:12:48 -0700 (PDT) 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=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b=KfE9dGv7; 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 8.43.85.97 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 2CB52385B52B for ; Fri, 19 May 2023 06:12:43 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2133.outbound.protection.outlook.com [40.107.255.133]) by sourceware.org (Postfix) with ESMTPS id 214D03858D28 for ; Fri, 19 May 2023 06:12:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 214D03858D28 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=mDgZELHlcdrFHfCy2cdcdjrh2WdUCBpIvZxOrqpLCHuxCUwefwOAp1gbBguKRPmLGvLuNxVLQKZsw7ZJpRttv4UXYj2p198MzN7Dy/qxyGbn8PI+/vRsufdfZnTl0qzM/3kPYcD3O7zl575oPoUILhugrfb5f57ZJNszy1YSALkeNGnrLQf6uarPKQK/jGogLVjMNk00q03q2MGJkKkqUgPTMuLLC9nQNh5jycMzedZ6W4mCbQGtYUmoFrOTG/d34W9I/NrD5DvO/3dBqsAMxLOC4rhB5N6NO6qa0LG4kbczzE090QpKEUxfE2Red1ut1xgWcu8iH/Cfp3tYbxLdQw== 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=h2i1gW4bBz3hupPkfbQy717+iwva1ROxmSqOweRVKMw=; b=RtFQ2NC9Yv1w2IPFeJwPw3iiXe7ntwupsK8AezFF4nUqTv1xn6JAUopkjfC0uAy+7juCrVO3JIkr9065/fatzjEwLDLYeY1WsyBVtRtovvpJNZFDp1bitBIm4jXBrTzuOkYZudrI0uCht98SeA+0OZrzVy0P0iq0CsvlXCovXOT8p85sBuV31KWDrj0pvJBbL/09xxydR5YkmYwvuB6PZeFpTG0d0iZr6+k0ZSxxP8oNqAQGKI5Y1ECjlI3xc52ZEe1ygKaTp9P/N74MC2YqqEhGDCN/v2kyan4ioLpRz/oRjejyLeobeznxTyLyrYV9uhjgHZFIdp2s/qaLKxsB8A== 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=h2i1gW4bBz3hupPkfbQy717+iwva1ROxmSqOweRVKMw=; b=KfE9dGv789/BSWD1Lwoqcpn9XncEQGl1ITbVVS2RxpvovZmlYIgXRNNrgX5UjT/5kttBhPVbhpWm3T8d9pUsf5zDBk4D/rcHpaKsV7hd6Vrf0HbKD4CC4CvS15vd3KB+4FkTQpYNvHbvIpH53iQi0ga/CfJMe7yREfJOmE/ErsY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cipunited.com; Received: from TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) by PSBPR04MB4022.apcprd04.prod.outlook.com (2603:1096:301:c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 06:12:09 +0000 Received: from TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::4016:87b:f0d1:b150]) by TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::4016:87b:f0d1:b150%7]) with mapi id 15.20.6411.021; Fri, 19 May 2023 06:12:09 +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, YunQiang Su Subject: [PATCH] MIPS: don't expand large block move Date: Fri, 19 May 2023 14:11:52 +0800 Message-Id: <20230519061152.3154332-1-yunqiang.su@cipunited.com> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: SGAP274CA0002.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::14) To TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR04MB6117:EE_|PSBPR04MB4022:EE_ X-MS-Office365-Filtering-Correlation-Id: 9267b151-bbcc-4e03-a7e2-08db582ffa0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xr2bDJauLYQscMOkc3xm0914dVuhacivmw/YjMpJkYKkbvtippYd7q69UiOyzpPX00smkJ0TS8Vd0zkHMBvemPbtjZEv/8QtT9wkXsDe6Z4FSc3h+sZM28ykwjD03JE7eX4bRWh5HHgI8iHmdcik2r7JR7WI933sP9lSg4yhAbUyBXc7LBBjEJmqThg40Ucky7haZjBKjLzzP+yeqN+NIeS0/t7dC7s5JFByVSgBr7ACjB3vf/NI/nKtbHUup3he3RwsoqMf7h69Z5xOoyG6mfvpkoWmddrd1TdDy37Dz+lTREcdbYuKtPntsndRGLLdMi6JhI8+Sr1pjPO5xuthXoKoSg/i/KhiLlvzmYfVbpnyD7cG1r63lZ/f1wm8fL1vTBALbK1CTt+xmJLS6mljTe5KHeYa44+8CO0FJRvAxWQpSwsGR5v0OKJwERxcSaCmVw8zOfXDTmb0qqcG8ZJ1H0dHnbQ++azRwBDb6DTj30zNHwM5genZkAHDf0krXLK+WtvG0dG+JOlBoIOsjrIJ1/td5lgjcMr/CQTRlAb6OBBC5MVY78ceD4V36JFtvDEJWAUkUr2RwY5YyI4v8mFAwbX3WWdj2GlspVs4PJQEheM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR04MB6117.apcprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(396003)(136003)(366004)(376002)(39830400003)(346002)(451199021)(52116002)(6486002)(6666004)(38100700002)(38350700002)(107886003)(26005)(186003)(1076003)(6512007)(6506007)(2616005)(83380400001)(36756003)(2906002)(66556008)(66476007)(66946007)(316002)(4326008)(6916009)(84970400001)(86362001)(8676002)(8936002)(5660300002)(41300700001)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d3Pbe+jHsG5rBJQmsYHhIaFDlBz4sxxgvytjMbWonnx9Kj29MtHP51dnzvSX16U8Tj2D36UaNiHFg+pIQ7noNtpq2FiCHUX/nfBAz3ER/CR2dvzaJvKPZzsycLyUPGtl8xsayRyPKhsRqlZs41+Vf2NGh8RnrCabQYStsZ+lU0U2k5hg3Kqo5In6pBu+iP1g35hTl3Q5oZ1QDCzc7MUQYvl7e4NjeNV6p+qA0NJZIWPKGprEu3u5pJvwZfBW9DDhq78+FpCS/sFvcmUnyfsgSo3CRcEtOAyv0A0vr31waDQY4o2GDHIArTNiwgnrpb1XX5VRx+yledGPCaLxITx525vHqOxq9v52dIU/wDlaQaEXWJHKlOafX8ORME0TVI0w9gODWGKAM0kWBMs8FWTYKurKS+onSk1675zDXWQu5Mgf3EAly8fYZqassn1YaPkItDZ0JGYwwSx01hDa2HQiXGr7rHTr/Iw9oDTIhXnZXJLNGdi8YQYxKTiL56TACYHsrpa8Ob0yi2pGMwr1RTwUm8uEaB7LZ0u1Iynb3+c+/yVDezCAQhLhJQPUWPWbMmnnlRGq7e6isyZ30TgpoAXDDnNTR2+auwNM1XkWgV1lYzOcVddafT0U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ange-CrossTenant-AuthSource: TYZPR04MB6117.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 06:12:08.7372 (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: nveCu23fvF0GNVJ+6pxxFsIt67r3wTMoU5qW3wTCIFSru7AEKAFtkfGSEma4XPRqby1BiJ0x40t9JCTUmRteER0u80+mg3g32oOR7ne3Jhc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSBPR04MB4022 X-Spam-Status: No, score=-13.0 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?1766301911315120422?= X-GMAIL-MSGID: =?utf-8?q?1766301911315120422?= On platform with LWL/LWR, mips_block_move_loop is always used, which expand __buildin_memcpy/strcpy to a loop of lwl/lwr/swl/swl etc. For short (normally <=64), it has better performance, but when the src/dest are long, use memcpy/strcpy lib call may have better performance. At the same time, lib call may be optimized with SIMD, so, on the platform with SIMD, lib call may have much better performace. gcc/ChangeLog: * config/mips/mips.cc (mips_expand_block_move): don't expand if length>=64. gcc/testsuite/ChangeLog: * gcc.target/mips/expand-block-move-large.c: New test. --- gcc/config/mips/mips.cc | 6 ++++++ .../gcc.target/mips/expand-block-move-large.c | 17 +++++++++++++++++ 2 files changed, 23 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 ca491b981a3..00f26d5e923 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -8313,6 +8313,12 @@ mips_expand_block_move (rtx dest, rtx src, rtx length) } else if (optimize) { + /* When the length is big enough, the lib call has better performace + than load/store insns. + In most platform, the value is about 64-128. + And in fact lib call may be optimized with SIMD */ + if (INTVAL(length) >= 64) + return false; mips_block_move_loop (dest, src, INTVAL (length), MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER); return true; 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..ae054551a2a --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/expand-block-move-large.c @@ -0,0 +1,17 @@ +/* { dg-options "isa_rev<=5" } */ +/* { 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]; + +NOCOMPRESSION void +foo (volatile int *x) +{ + __builtin_memcpy(&a[1], &b[1], 64); +}