From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1130) id 383F23889833; Tue, 17 Aug 2021 14:14:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 383F23889833 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Richard Sandiford To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10040] aarch64: Fix address mode for vec_concat pattern [PR100305] X-Act-Checkin: gcc X-Git-Author: Richard Sandiford X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: c29ea2f52e38dc69d0a1e60a0617b93f4bfcca71 X-Git-Newrev: 3e44c89e672ec18ce31edecf5b5bac980ce411e5 Message-Id: <20210817141443.383F23889833@sourceware.org> Date: Tue, 17 Aug 2021 14:14:43 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Aug 2021 14:14:43 -0000 https://gcc.gnu.org/g:3e44c89e672ec18ce31edecf5b5bac980ce411e5 commit r10-10040-g3e44c89e672ec18ce31edecf5b5bac980ce411e5 Author: Richard Sandiford Date: Tue Aug 17 15:14:22 2021 +0100 aarch64: Fix address mode for vec_concat pattern [PR100305] The load_pair_lanes patterns match a vec_concat of two adjacent 64-bit memory locations as a single 128-bit load. The Utq constraint made sure that the address was suitable for a 128-bit vector, but this meant that it allowed some addresses that aren't valid for the 64-bit element mode. Two obvious fixes were: (1) Continue to accept addresses that aren't valid for the element modes. This would mean changing the mode of operands[1] before printing it. It would also mean using a custom predicate instead of the current memory_operand. (2) Restrict addresses to the intersection of those that are valid element and vector addresses. The problem with (1) is that, as well as being more complicated, it doesn't deal with the fact that we still have a memory_operand for the second element. If we encourage the first operand to be outside the range of a normal element memory_operand, we'll have to reload the second operand to make it valid. This reload will often be dead code, but will be kept around because the RTL pattern makes it look as though the second element address is still needed. This patch therefore does (2) instead. As mentioned in the PR notes, I think we have a general problem with the way that the aarch64 port deals with paired addresses. There's nothing to guarantee that the two addresses will be reloaded in a way that keeps them “obviously” adjacent, so the rtx_equal_p conditions could fail if something rechecked them later. For this particular pattern, I think it would be better to teach simplify-rtx.c to fold the vec_concat to a normal vector memory reference, to remove any suggestion that targets should try to match the unsimplified form. That obviously wouldn't be suitable for backports though. gcc/ PR target/100305 * config/aarch64/constraints.md (Utq): Require the address to be valid for both the element mode and for V2DImode. gcc/testsuite/ PR target/100305 * gcc.c-torture/compile/pr100305.c: New test. (cherry picked from commit 668df9e769e7d89bcefa07f72b68dcae9a8f3970) Diff: --- gcc/config/aarch64/constraints.md | 2 ++ gcc/testsuite/gcc.c-torture/compile/pr100305.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md index 8cc6f508881..98c1f41c490 100644 --- a/gcc/config/aarch64/constraints.md +++ b/gcc/config/aarch64/constraints.md @@ -327,6 +327,8 @@ "@internal An address valid for loading or storing a 128-bit AdvSIMD register" (and (match_code "mem") + (match_test "aarch64_legitimate_address_p (GET_MODE (op), + XEXP (op, 0), 1)") (match_test "aarch64_legitimate_address_p (V2DImode, XEXP (op, 0), 1)"))) diff --git a/gcc/testsuite/gcc.c-torture/compile/pr100305.c b/gcc/testsuite/gcc.c-torture/compile/pr100305.c new file mode 100644 index 00000000000..43d78bf6542 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr100305.c @@ -0,0 +1,13 @@ +/* PR target/100305 */ + +typedef double v2df __attribute__((vector_size(16))); + +#define N 4096 +void consume (void *); +v2df +foo (void) +{ + double x[N+2]; + consume (x); + return (v2df) { x[N], x[N + 1] }; +}