From patchwork Wed Jan 17 14:59:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manos Anagnostakis X-Patchwork-Id: 84253 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 14EA43858428 for ; Wed, 17 Jan 2024 15:00:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id C7B1F3858C66 for ; Wed, 17 Jan 2024 14:59:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C7B1F3858C66 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C7B1F3858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705503575; cv=none; b=GiSUC7eXX/YyQfWd9ETwhvcKorAEDX6V+WKOHrVnLrQ0G8s1PYqi+BjMun+LwsYJIi1NZ2oGD9zD334mM8Nt1Fmvrk4Phy8pI78GAiC2MQ1Xoks9wEsBCBMhn4c8ipPSLM1CTVZk6lYyZgoHD31RKWlp8nXNUhzcNLNKjzyLAqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705503575; c=relaxed/simple; bh=MJR7zM+m4zCR+ELptMTlYLVS8575Y9IrY6e+K369mPQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=XE5ra0/Cnt6v7uSsLRUi5PtgnVxU+wxxUsZzt/AyNoGMGJQAOtig6z5vpOuK6ytWevfDspcD+nzZvC2xKrsuUavf9g0B3h5ty05voOKos7ugyKTtV03OOl8VLM/jdITlh+YLoksiTYZGAlWYTCYFhPiaYVukr8VD4QzfJxJvVFk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a2821884a09so936314466b.2 for ; Wed, 17 Jan 2024 06:59:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1705503571; x=1706108371; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mwpNwksZQsAuORC3Y4cTv+wHtRAKKY4ReKPP/A/HuBQ=; b=dWB+trwn3y2+tz4i6kGxWMHa2RNPPw1eLBCpVIb9zUyvttdBjpgeeQqjzb/Wabu867 1ri5g43Cl5R8/3OIWFId5y7L9IkhOTw+5UNseY3xXCg5Fy/xjlIycQOw7SKs7xMPSJwS JRCZkKkicEAuCn5HX956Z3VPQpeoRJ1ENOSz9CJEvL1ftg3MVRTD1tfrjL/H8ijjJTVW GASfeB3o+5voTmvhNOLMHAIBEBCdPwR/8q/PouyzqhcxbwVwQtlXZ2ypkTnCyenB8GAi octvj8ldRkot54KF0Ip7ztZ3TykMdkungiR2+88EfZNYkPxntHRWg9E2/hX2XuuUNrmg Ln7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705503571; x=1706108371; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mwpNwksZQsAuORC3Y4cTv+wHtRAKKY4ReKPP/A/HuBQ=; b=pDMYtSE9huLDR58NvNwHzpyAVaJVTMLZXpggnQMBxIfbojFl2ke6VhVQ9Op72cocWj NK5aUlT1kOjjYSq2xTYuChHQlA9f7lpWHbV6ygAvuugrwXnBgRsSRWJ0JvOri1GLiZfb ZxXo2xC/RDTHH+YO9aacpUENG4paSoUNw3p0NNTxuubhGZWbQNbDXyb+6lOE8n8LXTEu blH2nDvP0JTc62xTIsmeASN22Y7xwJbH+MZhzMHQKANEdi+hY0fzCYMWPQhihGGTfZ99 sTvF6IJdH4d4pJg7cjQ0jTAiFH+u0oo8PtSEFeCYRNthptlv2UMNIwzIIQCCKUL/AHaa o7wg== X-Gm-Message-State: AOJu0YzoG/G/fO7TJcEVthzYFCKYYwpQyRBsb9rwazw8v1ZK23Elyr24 c9j49kTBYrroYd2g2EfjCLQWP1bnpMoEBW+yb/sEMP1Ur70= X-Google-Smtp-Source: AGHT+IFRFKXlVnDW17/zTdvJQmEMljXwnvNDetFHIguOumSDlMGPPuesP6Jj6mmS8lMPWUzRG9L97g== X-Received: by 2002:a17:906:c24f:b0:a28:b35d:f240 with SMTP id bl15-20020a170906c24f00b00a28b35df240mr5105841ejb.10.1705503570954; Wed, 17 Jan 2024 06:59:30 -0800 (PST) Received: from manos-laptop.router.wind (adsl-179.79.107.0.tellas.gr. [79.107.0.179]) by smtp.gmail.com with ESMTPSA id v9-20020a170906380900b00a26ac037ff3sm7878103ejc.132.2024.01.17.06.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 06:59:30 -0800 (PST) From: Manos Anagnostakis To: gcc-patches@gcc.gnu.org Cc: Philipp Tomsich , Richard Sandiford , Kyrylo Tkachov , Manos Anagnostakis , Manolis Tsamis Subject: [PATCH] aarch64: Check the ldp/stp policy model correctly when mem ops are reversed. Date: Wed, 17 Jan 2024 16:59:21 +0200 Message-Id: <20240117145921.12313-1-manos.anagnostakis@vrull.eu> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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.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 The current ldp/stp policy framework implementation was missing cases, where the memory operands were reversed. Therefore the call to the framework function is moved after the lower mem check with the suitable parameters. Also removes the mode of aarch64_operands_ok_for_ldpstp, which becomes unused and triggers a warning on bootstrap. gcc/ChangeLog: * config/aarch64/aarch64-ldpstp.md: Remove unused mode. * config/aarch64/aarch64-protos.h (aarch64_operands_ok_for_ldpstp): Likewise. * config/aarch64/aarch64.cc (aarch64_operands_ok_for_ldpstp): Call on framework moved later. Signed-off-by: Manos Anagnostakis Co-Authored-By: Manolis Tsamis --- gcc/config/aarch64/aarch64-ldpstp.md | 22 +++++++++++----------- gcc/config/aarch64/aarch64-protos.h | 2 +- gcc/config/aarch64/aarch64.cc | 18 +++++++++--------- 3 files changed, 21 insertions(+), 21 deletions(-) -- 2.43.0 diff --git a/gcc/config/aarch64/aarch64-ldpstp.md b/gcc/config/aarch64/aarch64-ldpstp.md index b668fa8e2a6..b7c0bf05cd1 100644 --- a/gcc/config/aarch64/aarch64-ldpstp.md +++ b/gcc/config/aarch64/aarch64-ldpstp.md @@ -23,7 +23,7 @@ (match_operand:GPI 1 "memory_operand" "")) (set (match_operand:GPI 2 "register_operand" "") (match_operand:GPI 3 "memory_operand" ""))] - "aarch64_operands_ok_for_ldpstp (operands, true, mode)" + "aarch64_operands_ok_for_ldpstp (operands, true)" [(const_int 0)] { aarch64_finish_ldpstp_peephole (operands, true); @@ -35,7 +35,7 @@ (match_operand:GPI 1 "aarch64_reg_or_zero" "")) (set (match_operand:GPI 2 "memory_operand" "") (match_operand:GPI 3 "aarch64_reg_or_zero" ""))] - "aarch64_operands_ok_for_ldpstp (operands, false, mode)" + "aarch64_operands_ok_for_ldpstp (operands, false)" [(const_int 0)] { aarch64_finish_ldpstp_peephole (operands, false); @@ -47,7 +47,7 @@ (match_operand:GPF 1 "memory_operand" "")) (set (match_operand:GPF 2 "register_operand" "") (match_operand:GPF 3 "memory_operand" ""))] - "aarch64_operands_ok_for_ldpstp (operands, true, mode)" + "aarch64_operands_ok_for_ldpstp (operands, true)" [(const_int 0)] { aarch64_finish_ldpstp_peephole (operands, true); @@ -59,7 +59,7 @@ (match_operand:GPF 1 "aarch64_reg_or_fp_zero" "")) (set (match_operand:GPF 2 "memory_operand" "") (match_operand:GPF 3 "aarch64_reg_or_fp_zero" ""))] - "aarch64_operands_ok_for_ldpstp (operands, false, mode)" + "aarch64_operands_ok_for_ldpstp (operands, false)" [(const_int 0)] { aarch64_finish_ldpstp_peephole (operands, false); @@ -71,7 +71,7 @@ (match_operand:DREG 1 "memory_operand" "")) (set (match_operand:DREG2 2 "register_operand" "") (match_operand:DREG2 3 "memory_operand" ""))] - "aarch64_operands_ok_for_ldpstp (operands, true, mode)" + "aarch64_operands_ok_for_ldpstp (operands, true)" [(const_int 0)] { aarch64_finish_ldpstp_peephole (operands, true); @@ -83,7 +83,7 @@ (match_operand:DREG 1 "register_operand" "")) (set (match_operand:DREG2 2 "memory_operand" "") (match_operand:DREG2 3 "register_operand" ""))] - "aarch64_operands_ok_for_ldpstp (operands, false, mode)" + "aarch64_operands_ok_for_ldpstp (operands, false)" [(const_int 0)] { aarch64_finish_ldpstp_peephole (operands, false); @@ -96,7 +96,7 @@ (set (match_operand:VQ2 2 "register_operand" "") (match_operand:VQ2 3 "memory_operand" ""))] "TARGET_FLOAT - && aarch64_operands_ok_for_ldpstp (operands, true, mode) + && aarch64_operands_ok_for_ldpstp (operands, true) && (aarch64_tune_params.extra_tuning_flags & AARCH64_EXTRA_TUNE_NO_LDP_STP_QREGS) == 0" [(const_int 0)] @@ -111,7 +111,7 @@ (set (match_operand:VQ2 2 "memory_operand" "") (match_operand:VQ2 3 "register_operand" ""))] "TARGET_FLOAT - && aarch64_operands_ok_for_ldpstp (operands, false, mode) + && aarch64_operands_ok_for_ldpstp (operands, false) && (aarch64_tune_params.extra_tuning_flags & AARCH64_EXTRA_TUNE_NO_LDP_STP_QREGS) == 0" [(const_int 0)] @@ -128,7 +128,7 @@ (sign_extend:DI (match_operand:SI 1 "memory_operand" ""))) (set (match_operand:DI 2 "register_operand" "") (sign_extend:DI (match_operand:SI 3 "memory_operand" "")))] - "aarch64_operands_ok_for_ldpstp (operands, true, SImode)" + "aarch64_operands_ok_for_ldpstp (operands, true)" [(const_int 0)] { aarch64_finish_ldpstp_peephole (operands, true, SIGN_EXTEND); @@ -140,7 +140,7 @@ (zero_extend:DI (match_operand:SI 1 "memory_operand" ""))) (set (match_operand:DI 2 "register_operand" "") (zero_extend:DI (match_operand:SI 3 "memory_operand" "")))] - "aarch64_operands_ok_for_ldpstp (operands, true, SImode)" + "aarch64_operands_ok_for_ldpstp (operands, true)" [(const_int 0)] { aarch64_finish_ldpstp_peephole (operands, true, ZERO_EXTEND); @@ -162,7 +162,7 @@ (match_operand:DSX 1 "aarch64_reg_zero_or_fp_zero" "")) (set (match_operand: 2 "memory_operand" "") (match_operand: 3 "aarch64_reg_zero_or_fp_zero" ""))] - "aarch64_operands_ok_for_ldpstp (operands, false, mode)" + "aarch64_operands_ok_for_ldpstp (operands, false)" [(const_int 0)] { aarch64_finish_ldpstp_peephole (operands, false); diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index 4c70e8a4963..a0b142e0b94 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -1043,7 +1043,7 @@ int aarch64_ccmp_mode_to_code (machine_mode mode); bool extract_base_offset_in_addr (rtx mem, rtx *base, rtx *offset); bool aarch64_mergeable_load_pair_p (machine_mode, rtx, rtx); -bool aarch64_operands_ok_for_ldpstp (rtx *, bool, machine_mode); +bool aarch64_operands_ok_for_ldpstp (rtx *, bool); bool aarch64_operands_adjust_ok_for_ldpstp (rtx *, bool, machine_mode); bool aarch64_mem_ok_with_ldpstp_policy_model (rtx, bool, machine_mode); bool aarch64_ldpstp_operand_mode_p (machine_mode); diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index e6bd3fd0bb4..5a174d34e87 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -27671,12 +27671,10 @@ aarch64_mem_ok_with_ldpstp_policy_model (rtx mem, bool load, machine_mode mode) } /* Given OPERANDS of consecutive load/store, check if we can merge - them into ldp/stp. LOAD is true if they are load instructions. - MODE is the mode of memory operands. */ + them into ldp/stp. LOAD is true if they are load instructions. */ bool -aarch64_operands_ok_for_ldpstp (rtx *operands, bool load, - machine_mode mode) +aarch64_operands_ok_for_ldpstp (rtx *operands, bool load) { enum reg_class rclass_1, rclass_2; rtx mem_1, mem_2, reg_1, reg_2; @@ -27705,10 +27703,6 @@ aarch64_operands_ok_for_ldpstp (rtx *operands, bool load, if (MEM_VOLATILE_P (mem_1) || MEM_VOLATILE_P (mem_2)) return false; - /* Check if mem_1 is ok with the ldp-stp policy model. */ - if (!aarch64_mem_ok_with_ldpstp_policy_model (mem_1, load, mode)) - return false; - /* Check if the addresses are in the form of [base+offset]. */ bool reversed = false; if (!aarch64_check_consecutive_mems (&mem_1, &mem_2, &reversed)) @@ -27720,7 +27714,13 @@ aarch64_operands_ok_for_ldpstp (rtx *operands, bool load, /* The lower memory access must be a mem-pair operand. */ rtx lower_mem = reversed ? mem_2 : mem_1; - if (!aarch64_mem_pair_operand (lower_mem, GET_MODE (lower_mem))) + machine_mode lower_mem_mode = GET_MODE (lower_mem); + if (!aarch64_mem_pair_operand (lower_mem, lower_mem_mode)) + return false; + + /* Check if lower_mem is ok with the ldp-stp policy model. */ + if (!aarch64_mem_ok_with_ldpstp_policy_model (lower_mem, load, + lower_mem_mode)) return false; if (REG_P (reg_1) && FP_REGNUM_P (REGNO (reg_1)))