From patchwork Wed Jan 24 05:15:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 191363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp785835dyi; Tue, 23 Jan 2024 21:16:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWMt0tX94FwTPMZoBwDo3GaREjfFEnv5ojW7EIpFHGFhCvcGK4mXjUs050bKfPlWOCbqUw X-Received: by 2002:a05:6214:2b09:b0:681:86c:ac4 with SMTP id jx9-20020a0562142b0900b00681086c0ac4mr2332736qvb.74.1706073410832; Tue, 23 Jan 2024 21:16:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706073410; cv=pass; d=google.com; s=arc-20160816; b=qSr9db2o+iPnZYhjBGkF5fYiu7FyKr4wwIJu4NrNscWn92g8Kr0ug45lB4OhFH9f0r igywW4hc3i46gAqrOGVltKHhXFF6VxubepumpKczsrD5m+jWhhosV6i6k+zPQACQ2h8O tpBz7r1oSSMfuIxj3eqD5sZeaVIKylL7AJ6mIwHpt3T9UIygfaQTnz2L+RVnM2c8jc6v 5pWfnUrRVOlBKoEDEmno7bvZgQmJQKwIRqlprS4lZd4PgZCxwRzMwPlXU+SjTJNVGG3s 42ugkCo1z6NfWZEulzpfo9K6cE9io8YHkdFXwIORK8F/ks9LPlBXRvp8NUdwokk6uzPh 1RuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=W147Sv5ZeYtPDOnResQNTbn9AI5AfP5/4XiNDLD6o/w=; fh=Y7J/tVlIhSfzyR85eMYVdvBvIbBpAAqmWIKjKxwXJeI=; b=EVyNBlmfxACmyFUIROAsJGECcMR99CO9tkZxdxJvmqJ2vdrggABle+jnySQYQzhRgk shE1PaYXVnAzh/h+6Xzw19LpomnuLDjGaumOma2spSYubxvaYu9GyJrIMUnTyeiWmg2b Hrs9RYdcbmwVUaXpHLCCF3md6h4towz8wYC6LoVyiSfCAqMRxhCIyOutthojQg5ZucKa 6AR0gfxl2Uj1m/1z5xjKsywLBogFDtQ6KY86N0ZN2njeC6nuffiDow8xJUkiDJ3I2dGI mWhjzkZdp+XBaTp1tkg+pS/GISGEVZ0MqLCqN4KZigFJq5RG+eS2e1G+gZnIY92mSiSq PvTg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QqGCEpg0; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id x13-20020a0cda0d000000b00681954c319asi9664067qvj.6.2024.01.23.21.16.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 21:16:50 -0800 (PST) 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=@gmail.com header.s=20230601 header.b=QqGCEpg0; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 76B8C385840E for ; Wed, 24 Jan 2024 05:16:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id DEEF23858D1E for ; Wed, 24 Jan 2024 05:16:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DEEF23858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DEEF23858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::532 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706073373; cv=none; b=ENX4OooiGR5P6Ee1dfdbx8gxtqQO2KWsFEW5GS+g5O77SlOWmnoaiVl3NJduebZAvaRUTzz2sUakdK4wgbw4dxwNj8Mc7v4RNP9VvJk0LN78outSO7EBhr7vFCb3YuWItsmBksdzzmGFl4nWtIhnO4vM6oo4vBrncMnHnkRliY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706073373; c=relaxed/simple; bh=hJyfYnevaEi/ivJ9i/6AvTXBzgXchu+tYOU+DjjVMpg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=vqnBJON7YRMOW5swa2CJRd/KYn93l1zJ59t/vqJBL7j2ok3jdDzq2tLVtsyBZxdD5higHs0/1e8zJF13g9oDJgmHBH/EeavNQkvpQ2W/u6ILcs2Y7PcoQvWOHtRKoZAr/mpIrEB/5FhEtbutA+ZeVUOxXZxItaQ6J+3ptw+a1pE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5ce9555d42eso4278536a12.2 for ; Tue, 23 Jan 2024 21:16:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706073369; x=1706678169; 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=W147Sv5ZeYtPDOnResQNTbn9AI5AfP5/4XiNDLD6o/w=; b=QqGCEpg0C4vMD3VGjrmWQ0Zxaoj6xyAk2GT4+sV/iGfQ0EUHTDD3/Jt2D5DC2rRBap Q4xsdgrLBzwqvtd4gOxeq0DsbE+88eJ8aih7xrLsqXDqNQHyg8/rYcptEzFVwgYJKgNp kvtWMSH5FmUzyFfl8P8s5HbC9AwUtL6TTJz+jfBaeGHiTu0OrMpxUlRlE1T9LUl30+Oc VRO0LowkEWBnVKlOCF1XASDVshl5hM/TpuGIhqW5KxsOmRgdAixCj6ugJdack6qYezde NP+8AQwd89RRuOSOAUZsPZYbu48zLi4zd9082d6tybv3OAdD0ve0KKfBBruRSF7Qgfgw cuoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706073369; x=1706678169; 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=W147Sv5ZeYtPDOnResQNTbn9AI5AfP5/4XiNDLD6o/w=; b=AQD8uCV9L1LlTzEJgiyC9VLSZurM17cBfhvwfKknqUxry5JLNANftxUTKx3uk09xXS 1o3dTjGcGQ00OMmRcFeVi+yYGxKlY6NWj0MSQTPKDbwPUaiAjZtF/JF9yYhhmCgyJwWm 2qAP+WQ0mEeTT/jou40arTQA3qHkmmqVTMKveDQ2YuCgmV5wWnK7B6n89rfhojkWOiUw J3+CR3uSKhOEu48ccDc0zQ/9GztbHZlDO5wohevMfDqLLlIl+ghbEyj95UfoT3UJ4kHq 9qf76QBj/cUwyxaEQPpEJ+sGk6pX/FGv6zXAB/Ypo4BrL83vxHBvR1nnvxJ03NF/ckUL ABrw== X-Gm-Message-State: AOJu0YyrMP8wcaPu/6b3cJ1AUx4q8pWJbViq/ra6CQZS96u0g9HYDSO7 9klgmOzDryPsxYVgQdVPyhUIalpENOsL/+XzR2sLy1svDopShfdCZHRSHMoN X-Received: by 2002:a05:6a20:1b1f:b0:19b:5c7e:ae41 with SMTP id ch31-20020a056a201b1f00b0019b5c7eae41mr332114pzb.84.1706073369206; Tue, 23 Jan 2024 21:16:09 -0800 (PST) Received: from octofox.hsd1.ca.comcast.net (c-73-63-239-93.hsd1.ca.comcast.net. [73.63.239.93]) by smtp.gmail.com with ESMTPSA id fk19-20020a056a003a9300b006db87354a8fsm12541376pfb.119.2024.01.23.21.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 21:16:08 -0800 (PST) From: Max Filippov To: gcc-patches@gcc.gnu.org Cc: Takayuki 'January June' Suwa Subject: [PATCH v2] xtensa: Make full transition to LRA Date: Tue, 23 Jan 2024 21:15:30 -0800 Message-Id: <20240124051530.1146739-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, GIT_PATCH_0, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1765333464080714067 X-GMAIL-MSGID: 1788947633007298683 From: Takayuki 'January June' Suwa gcc/ChangeLog: * config/xtensa/constraints.md (R, T, U): Change define_constraint to define_memory_constraint. * config/xtensa/predicates.md (move_operand): Don't check that a constant pool operand size is a multiple of UNITS_PER_WORD. * config/xtensa/xtensa.cc (xtensa_lra_p, TARGET_LRA_P): Remove. (xtensa_emit_move_sequence): Remove "if (reload_in_progress)" clause as it can no longer be true. (fixup_subreg_mem): Drop function. (xtensa_output_integer_literal_parts): Consider 16-bit wide constants. (xtensa_legitimate_constant_p): Add short-circuit path for integer load instructions. Don't check that mode size is at least UNITS_PER_WORD. * config/xtensa/xtensa.md (movsf): Use can_create_pseudo_p() rather reload_in_progress and reload_completed. (doloop_end): Drop operand 2. (movhi_internal): Add alternative loading constant from a literal pool. * config/xtensa/xtensa.opt (mlra): Change to no effect. --- gcc/config/xtensa/constraints.md | 26 ++++++------------ gcc/config/xtensa/predicates.md | 4 +-- gcc/config/xtensa/xtensa.cc | 46 +++++--------------------------- gcc/config/xtensa/xtensa.md | 15 +++++------ gcc/config/xtensa/xtensa.opt | 4 +-- 5 files changed, 24 insertions(+), 71 deletions(-) diff --git a/gcc/config/xtensa/constraints.md b/gcc/config/xtensa/constraints.md index 5cade1db8ff1..dc6ffb5ba15c 100644 --- a/gcc/config/xtensa/constraints.md +++ b/gcc/config/xtensa/constraints.md @@ -123,29 +123,19 @@ (and (match_code "const_int") (match_test "! xtensa_split1_finished_p ()")))) -;; Memory constraints. Do not use define_memory_constraint here. Doing so -;; causes reload to force some constants into the constant pool, but since -;; the Xtensa constant pool can only be accessed with L32R instructions, it -;; is always better to just copy a constant into a register. Instead, use -;; regular constraints but add a check to allow pseudos during reload. +;; Memory constraints. -(define_constraint "R" +(define_memory_constraint "R" "Memory that can be accessed with a 4-bit unsigned offset from a register." - (ior (and (match_code "mem") - (match_test "smalloffset_mem_p (op)")) - (and (match_code "reg") - (match_test "reload_in_progress - && REGNO (op) >= FIRST_PSEUDO_REGISTER")))) + (and (match_code "mem") + (match_test "smalloffset_mem_p (op)"))) -(define_constraint "T" +(define_memory_constraint "T" "Memory in a literal pool (addressable with an L32R instruction)." (and (match_code "mem") (match_test "!TARGET_CONST16 && constantpool_mem_p (op)"))) -(define_constraint "U" +(define_memory_constraint "U" "Memory that is not in a literal pool." - (ior (and (match_code "mem") - (match_test "! constantpool_mem_p (op)")) - (and (match_code "reg") - (match_test "reload_in_progress - && REGNO (op) >= FIRST_PSEUDO_REGISTER")))) + (and (match_code "mem") + (match_test "! constantpool_mem_p (op)"))) diff --git a/gcc/config/xtensa/predicates.md b/gcc/config/xtensa/predicates.md index 672fb003a6c5..dd77911e3b70 100644 --- a/gcc/config/xtensa/predicates.md +++ b/gcc/config/xtensa/predicates.md @@ -143,9 +143,7 @@ (define_predicate "move_operand" (ior (ior (match_operand 0 "register_operand") - (and (match_operand 0 "memory_operand") - (match_test "!constantpool_mem_p (op) - || GET_MODE_SIZE (mode) % UNITS_PER_WORD == 0"))) + (match_operand 0 "memory_operand")) (ior (and (match_code "const_int") (match_test "(GET_MODE_CLASS (mode) == MODE_INT && xtensa_simm12b (INTVAL (op))) diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index a4f8e3e49d06..22b4416f48e4 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -115,7 +115,6 @@ static enum internal_test map_test_to_internal_test (enum rtx_code); static rtx gen_int_relational (enum rtx_code, rtx, rtx); static rtx gen_float_relational (enum rtx_code, rtx, rtx); static rtx gen_conditional_move (enum rtx_code, machine_mode, rtx, rtx); -static rtx fixup_subreg_mem (rtx); static struct machine_function * xtensa_init_machine_status (void); static rtx xtensa_legitimize_tls_address (rtx); static rtx xtensa_legitimize_address (rtx, rtx, machine_mode); @@ -192,7 +191,6 @@ static void xtensa_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED, HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset, tree function); -static bool xtensa_lra_p (void); static rtx xtensa_delegitimize_address (rtx); @@ -286,9 +284,6 @@ static rtx xtensa_delegitimize_address (rtx); #undef TARGET_CANNOT_FORCE_CONST_MEM #define TARGET_CANNOT_FORCE_CONST_MEM xtensa_cannot_force_const_mem -#undef TARGET_LRA_P -#define TARGET_LRA_P xtensa_lra_p - #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P xtensa_legitimate_address_p @@ -1333,35 +1328,10 @@ xtensa_emit_move_sequence (rtx *operands, machine_mode mode) operands[1] = xtensa_copy_incoming_a7 (operands[1]); - /* During reload we don't want to emit (subreg:X (mem:Y)) since that - instruction won't be recognized after reload, so we remove the - subreg and adjust mem accordingly. */ - if (reload_in_progress) - { - operands[0] = fixup_subreg_mem (operands[0]); - operands[1] = fixup_subreg_mem (operands[1]); - } return 0; } -static rtx -fixup_subreg_mem (rtx x) -{ - if (GET_CODE (x) == SUBREG - && GET_CODE (SUBREG_REG (x)) == REG - && REGNO (SUBREG_REG (x)) >= FIRST_PSEUDO_REGISTER) - { - rtx temp = - gen_rtx_SUBREG (GET_MODE (x), - reg_equiv_mem (REGNO (SUBREG_REG (x))), - SUBREG_BYTE (x)); - x = alter_subreg (&temp, true); - } - return x; -} - - /* Check if an incoming argument in a7 is expected to be used soon and if OPND is a register or register pair that includes a7. If so, create a new pseudo and copy a7 into that pseudo at the very @@ -2355,7 +2325,7 @@ xtensa_legitimate_address_p (machine_mode mode, rtx addr, bool strict, code_helper) { /* Allow constant pool addresses. */ - if (mode != BLKmode && GET_MODE_SIZE (mode) >= UNITS_PER_WORD + if (mode != BLKmode && ! TARGET_CONST16 && constantpool_address_p (addr) && ! xtensa_tls_referenced_p (addr)) return true; @@ -3280,7 +3250,7 @@ xtensa_output_integer_literal_parts (FILE *file, rtx x, int size) fputs (", ", file); xtensa_output_integer_literal_parts (file, second, size / 2); } - else if (size == 4) + else if (size == 4 || size == 2) { output_addr_const (file, x); } @@ -4952,6 +4922,10 @@ xtensa_trampoline_init (rtx m_tramp, tree fndecl, rtx chain) static bool xtensa_legitimate_constant_p (machine_mode mode ATTRIBUTE_UNUSED, rtx x) { + if (CONST_INT_P (x)) + return TARGET_AUTO_LITPOOLS || TARGET_CONST16 + || xtensa_simm12b (INTVAL (x)); + return !xtensa_tls_referenced_p (x); } @@ -5393,12 +5367,4 @@ xtensa_delegitimize_address (rtx op) return op; } -/* Implement TARGET_LRA_P. */ - -static bool -xtensa_lra_p (void) -{ - return TARGET_LRA; -} - #include "gt-xtensa.h" diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 20af1cbfbd03..184b44e45f49 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -1328,8 +1328,8 @@ }) (define_insn "movhi_internal" - [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,a,U,*a,*A") - (match_operand:HI 1 "move_operand" "M,d,r,I,Y,U,r,*A,*r"))] + [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,a,a,U,*a,*A") + (match_operand:HI 1 "move_operand" "M,d,r,I,Y,T,U,r,*A,*r"))] "xtensa_valid_move (HImode, operands)" "@ movi.n\t%0, %x1 @@ -1337,13 +1337,14 @@ mov\t%0, %1 movi\t%0, %x1 movi\t%0, %1 + %v1l32r\t%0, %1 %v1l16ui\t%0, %1 %v0s16i\t%1, %0 rsr\t%0, ACCLO wsr\t%1, ACCLO" - [(set_attr "type" "move,move,move,move,move,load,store,rsr,wsr") + [(set_attr "type" "move,move,move,move,move,load,load,store,rsr,wsr") (set_attr "mode" "HI") - (set_attr "length" "2,2,3,3,3,3,3,3,3")]) + (set_attr "length" "2,2,3,3,3,3,3,3,3,3")]) ;; 8-bit Integer moves @@ -1420,7 +1421,7 @@ if ((!register_operand (operands[0], SFmode) && !register_operand (operands[1], SFmode)) || (FP_REG_P (xt_true_regnum (operands[0])) - && !(reload_in_progress | reload_completed) + && can_create_pseudo_p () && (constantpool_mem_p (operands[1]) || CONSTANT_P (operands[1])))) operands[1] = force_reg (SFmode, operands[1]); @@ -2368,14 +2369,12 @@ (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1))) - (unspec [(const_int 0)] UNSPEC_LSETUP_END) - (clobber (match_dup 2))])] ; match_scratch + (unspec [(const_int 0)] UNSPEC_LSETUP_END)])] "TARGET_LOOPS && optimize" { /* The loop optimizer doesn't check the predicates... */ if (GET_MODE (operands[0]) != SImode) FAIL; - operands[2] = gen_rtx_SCRATCH (SImode); }) diff --git a/gcc/config/xtensa/xtensa.opt b/gcc/config/xtensa/xtensa.opt index f16b53bf409f..19c9bd37a187 100644 --- a/gcc/config/xtensa/xtensa.opt +++ b/gcc/config/xtensa/xtensa.opt @@ -38,8 +38,8 @@ Target RejectNegative Joined UInteger Var(xtensa_extra_l32r_costs) Init(0) Set extra memory access cost for L32R instruction, in clock-cycle units. mlra -Target Mask(LRA) -Use LRA instead of reload (transitional). +Target Ignore +Does nothing. Preserved for backward compatibility. mtarget-align Target