public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 3/6] gcc/expmed.c: Ensure vector modes are tieable before extraction
@ 2021-10-22 14:33 Jonathan Wright
  2021-10-22 14:42 ` Richard Sandiford
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wright @ 2021-10-22 14:33 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Sandiford, Kyrylo Tkachov

[-- Attachment #1: Type: text/plain, Size: 905 bytes --]

Hi,

Extracting a bitfield from a vector can be achieved by casting the
vector to a new type whose elements are the same size as the desired
bitfield, before generating a subreg. However, this is only an
optimization if the original vector can be accessed in the new
machine mode without first being copied - a condition denoted by the
TARGET_MODES_TIEABLE_P hook.

This patch adds a check to make sure that the vector modes are
tieable before attempting to generate a subreg. This is a necessary
prerequisite for a subsequent patch that will introduce new machine
modes for Arm Neon vector-tuple types.

Bootstrapped and regression tested on aarch64-none-linux-gnu and
x86_64-pc-linux-gnu - no issues.

Ok for master?

Thanks,
Jonathan

---

gcc/ChangeLog:

2021-10-11  Jonathan Wright  <jonathan.wright@arm.com>

	* expmed.c (extract_bit_field_1): Ensure modes are tieable.

[-- Attachment #2: rb14926.patch --]
[-- Type: application/octet-stream, Size: 713 bytes --]

diff --git a/gcc/expmed.c b/gcc/expmed.c
index 59734d4841cbd2056a7d5bda9134af79c8024c87..f58fb9d877d66809b39253ccdc803f0ecb009326 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -1734,7 +1734,8 @@ extract_bit_field_1 (rtx str_rtx, poly_uint64 bitsize, poly_uint64 bitnum,
       FOR_EACH_MODE_FROM (new_mode, new_mode)
 	if (known_eq (GET_MODE_SIZE (new_mode), GET_MODE_SIZE (GET_MODE (op0)))
 	    && known_eq (GET_MODE_UNIT_SIZE (new_mode), GET_MODE_SIZE (tmode))
-	    && targetm.vector_mode_supported_p (new_mode))
+	    && targetm.vector_mode_supported_p (new_mode)
+	    && targetm.modes_tieable_p (GET_MODE (op0), new_mode))
 	  break;
       if (new_mode != VOIDmode)
 	op0 = gen_lowpart (new_mode, op0);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-22 14:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 14:33 [PATCH 3/6] gcc/expmed.c: Ensure vector modes are tieable before extraction Jonathan Wright
2021-10-22 14:42 ` Richard Sandiford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).