From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id 18EF43858414 for ; Mon, 6 Sep 2021 10:51:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 18EF43858414 Received: by mail-ej1-x62f.google.com with SMTP id t19so12664429ejr.8 for ; Mon, 06 Sep 2021 03:51:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zeWFZ6ddYvIwW3wfdtyRitjgRtYBXYi289hhoKo/1a8=; b=Ox7xhSlvjxig1oclKebYSG9XnxAu+5sT98SfuXQAH5bQC9GyNe/8Sw4iiGNUFQQcV7 YqhOtISLsxsEvCfC+qt+18h4IpcjW+G8CM9MK1lY5zBS276do1jzFwgnXGcQupO/Bccy wUdLCcGAQCGgv1tZnb5Ia1iOY1nBQjQpiS+pmdcw7FzSevrLMZ7D771jpXQ6xpDvsdCn m+P+Vb88ogKnbJjwcfFdYTcduRYMJ9X8tjh+/yglklcYVMDCHE13fCBSeyiHtQZ92GFP YMbMQt9ZDIC51jxh9omx0TsZpSjN9k+Gfrq3WSo5tchR6AnHL4SC8+MIa8PWP0zWeRkj NMfQ== X-Gm-Message-State: AOAM532ibK5zbCRy2zm3L4vWVxp4Eja7Gb7F/oAU4Mjzge7UIvL98G0S e4sdZvdAEXV0i5dp8m50XeVYKutWq1gbnoJQ7As= X-Google-Smtp-Source: ABdhPJzC7dppnblQu9G3LjehkBXpOLwr0pUEvg81Q38Npxa/lTl3g5aWzvoIGGVtIqIUWPhsouLStEKw76eR7z+cnHY= X-Received: by 2002:a17:906:7208:: with SMTP id m8mr13016150ejk.82.1630925504047; Mon, 06 Sep 2021 03:51:44 -0700 (PDT) MIME-Version: 1.0 References: <20210906104018.2697413-1-rearnsha@arm.com> <20210906104018.2697413-4-rearnsha@arm.com> In-Reply-To: <20210906104018.2697413-4-rearnsha@arm.com> From: Richard Biener Date: Mon, 6 Sep 2021 12:51:33 +0200 Message-ID: Subject: Re: [PATCH 3/3] gimple: allow more folding of memcpy [PR102125] To: Richard Earnshaw Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-List-Received-Date: Mon, 06 Sep 2021 10:51:46 -0000 On Mon, Sep 6, 2021 at 12:40 PM Richard Earnshaw wrote: > > > The current restriction on folding memcpy to a single element of size > MOVE_MAX is excessively cautious on most machines and limits some > significant further optimizations. So relax the restriction provided > the copy size does not exceed MOVE_MAX * MOVE_RATIO and that a SET > insn exists for moving the value into machine registers. > > Note that there were already checks in place for having misaligned > move operations when one or more of the operands were unaligned. > > On Arm this now permits optimizing > > uint64_t bar64(const uint8_t *rData1) > { > uint64_t buffer; > memcpy(&buffer, rData1, sizeof(buffer)); > return buffer; > } > > from > ldr r2, [r0] @ unaligned > sub sp, sp, #8 > ldr r3, [r0, #4] @ unaligned > strd r2, [sp] > ldrd r0, [sp] > add sp, sp, #8 > > to > mov r3, r0 > ldr r0, [r0] @ unaligned > ldr r1, [r3, #4] @ unaligned > > PR target/102125 - (ARM Cortex-M3 and newer) missed optimization. memcpy not needed operations OK. Thanks, Richard. > gcc/ChangeLog: > > PR target/102125 > * gimple-fold.c (gimple_fold_builtin_memory_op): Allow folding > memcpy if the size is not more than MOVE_MAX * MOVE_RATIO. > --- > gcc/gimple-fold.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) >