aboutsummaryrefslogtreecommitdiff
path: root/gcc/explow.h
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2024-06-13 12:48:21 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2024-06-13 12:48:21 +0100
commit0970ff46ba6330fc80e8736fc05b2eaeeae0b6a0 (patch)
treeb97e9211988dd560d55a7d3fdfeacd1ce24bf87d /gcc/explow.h
parent3dac1049c1211e6d06c2536b86445a6334c3866d (diff)
downloadgcc-0970ff46ba6330fc80e8736fc05b2eaeeae0b6a0.zip
gcc-0970ff46ba6330fc80e8736fc05b2eaeeae0b6a0.tar.gz
gcc-0970ff46ba6330fc80e8736fc05b2eaeeae0b6a0.tar.bz2
aarch64: Fix invalid nested subregs [PR115464]
The testcase extracts one arm_neon.h vector from a pair (one subreg) and then reinterprets the result as an SVE vector (another subreg). Each subreg makes sense individually, but we can't fold them together into a single subreg: it's 32 bytes -> 16 bytes -> 16*N bytes, but the interpretation of 32 bytes -> 16*N bytes depends on whether N==1 or N>1. Since the second subreg makes sense individually, simplify_subreg should bail out rather than ICE on it. simplify_gen_subreg will then do the same (because it already checks validate_subreg). This leaves simplify_gen_subreg returning null, requiring the caller to take appropriate action. I think this is relatively likely to occur elsewhere, so the patch adds a helper for forcing a subreg, allowing a temporary pseudo to be created where necessary. I'll follow up by using force_subreg in more places. This patch is intended to be a minimal backportable fix for the PR. gcc/ PR target/115464 * simplify-rtx.cc (simplify_context::simplify_subreg): Don't try to fold two subregs together if their relationship isn't known at compile time. * explow.h (force_subreg): Declare. * explow.cc (force_subreg): New function. * config/aarch64/aarch64-sve-builtins-base.cc (svset_neonq_impl::expand): Use it instead of simplify_gen_subreg. gcc/testsuite/ PR target/115464 * gcc.target/aarch64/sve/acle/general/pr115464.c: New test.
Diffstat (limited to 'gcc/explow.h')
-rw-r--r--gcc/explow.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/explow.h b/gcc/explow.h
index 16aa02c..cbd1fcb 100644
--- a/gcc/explow.h
+++ b/gcc/explow.h
@@ -42,6 +42,8 @@ extern rtx copy_to_suggested_reg (rtx, rtx, machine_mode);
Args are mode (in case value is a constant) and the value. */
extern rtx force_reg (machine_mode, rtx);
+extern rtx force_subreg (machine_mode, rtx, machine_mode, poly_uint64);
+
/* Return given rtx, copied into a new temp reg if it was in memory. */
extern rtx force_not_mem (rtx);