From patchwork Tue Jun 25 11:53:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 1952053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4W7jsW18Jpz20X1 for ; Tue, 25 Jun 2024 21:53:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DF92538432E7 for ; Tue, 25 Jun 2024 11:53:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 2A30E384475E for ; Tue, 25 Jun 2024 11:53:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A30E384475E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2A30E384475E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719316403; cv=none; b=MZeOv/ItriQT/pJuFzJzJRxIdvrXOuZQDGTpnlI/iHoVZZqVcIWhdYrrv+H+wsojGtPMpi+9+Qn2SvAv+hAWk9hQGuNDMCHHIIqbca9xtrR+7C7XKWew10XzJBIMYvc2sqFBccEhclFal7L+ydxlE4oSSIo/q8SjQEMfgOnoac8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719316403; c=relaxed/simple; bh=u1r9OIq/xerVwsd/s5070u8F2DQa/2zWlkJl8+pkSH8=; h=Message-ID:Date:MIME-Version:To:From:Subject; b=ui4bfg6xmxAfPRSryhkwzbyGtNWmmjLC/CKRzUfVOskEpIdpE2fFAua9ClOeEHpyifLH/znURR/cJkJg4wxIDJixrZ7rx/W7gw7KzaoSzmh7x5HcPtfN1mjwxHo7krVqQLTLLSdUFk2hT4Md0ZMwAShlP5dPkKDYeVzpBtJKkWg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 948A1339; Tue, 25 Jun 2024 04:53:42 -0700 (PDT) Received: from [10.1.39.70] (PW03YX1L.arm.com [10.1.39.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5429A3F766; Tue, 25 Jun 2024 04:53:17 -0700 (PDT) Message-ID: <7d96577f-6d5c-40e3-9fe6-14c82031a2fa@arm.com> Date: Tue, 25 Jun 2024 12:53:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "gcc-patches@gcc.gnu.org" Cc: "Richard Earnshaw (lists)" From: "Andre Vieira (lists)" Subject: [PATCH] arm: make arm_predict_doloop_p reject loops with calls X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_LOTSOFHASH, KAM_SHORT, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, With the introduction of low overhead loops in https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=3dfc28dbbd21b1d708aa40064380ef4c42c994d7 we defined arm_predict_doloop_p, this is meant to be a low-weight check to rule out loops we are not considering for doloop optimization and it is used by other passes to prevent optimizations that may hurt the doloop optimization later on. The reason these are meant to be lightweight is because it's used by pre-RTL optimizations, meaning we can't do the same checks that doloop does. After the definition of arm_predict_doloop_p, when testing for armv8.1-m.main, tree-ssa/ivopts-3.c failed the scan-dump check as the dump now matched an extra '!= 0' introduced by: Doloop cmp iv use: if (ivtmp_1 != 0) Predict loop 1 can perform doloop optimization later. where previously we had: Predict doloop failure due to target specific checks. and after this patch: Predict doloop failure due to call in loop. Predict doloop failure due to target specific checks. Added a copy of the original tree-ssa/ivopts-3.c as a target specifc test to check for the new dump message. Ran a regression test for arm-none-eabi with -march=armv8.1-m.main+mve/-mfpu=auto/-mthumb/-mfloat-abi=hard. OK for trunk? gcc/ChangeLog: * confir/arm/arm.cc (arm_predict_doloop_p): Reject loops with function calls that are not builtins. gcc/testsuite/ChangeLog: * gcc.target/arm/mve/ivopts-3.c: New test. diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 7d67d2cfee9f4edc91f187e940be40c07ff726cd..6dab65f493beb76089f80966a73a46afe037e6f9 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -35587,6 +35587,22 @@ arm_predict_doloop_p (struct loop *loop) " loop bb complexity.\n"); return false; } + else + { + gimple_stmt_iterator gsi = gsi_after_labels (loop->header); + while (!gsi_end_p (gsi)) + { + if (is_gimple_call (gsi_stmt (gsi)) + && !gimple_call_builtin_p (gsi_stmt (gsi))) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "Predict doloop failure due to" + " call in loop.\n"); + return false; + } + gsi_next (&gsi); + } + } return true; } diff --git a/gcc/testsuite/gcc.target/arm/mve/ivopts-3.c b/gcc/testsuite/gcc.target/arm/mve/ivopts-3.c new file mode 100644 index 0000000000000000000000000000000000000000..19b2442ef12cbf13d51761ae93c7c81bb5bc07c4 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/mve/ivopts-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ivopts-details" } */ + +void f2 (void); + +int main (void) +{ + int i; + for (i = 0; i < 10; i++) + f2 (); +} + +/* { dg-final { scan-tree-dump "Predict doloop failure due to call in loop." "ivopts" } } */