[PATCH]middle-end: relax validate_subreg to allow paradoxical subregs that change mode

Tamar Christina tamar.christina@arm.com
Tue Sep 19 12:30:22 GMT 2023


Hi All,

This patch relaxes the subreg invariant that you can only change modes
or make it paradoxical in one conversion. i.e. it now allows subreg:V2DI (reg:DF ..))

This is well defined in the generic sense and allowing it would enable
you to write RTL without the extra moves which can be interfered with by
combine.

Patch has been pre-approved[1], but giving people chance to object

[1] https://gcc.gnu.org/pipermail/gcc-patches/2023-September/629119.html

Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-linux-gnu,
powerpc64le-unknown-linux-gnu and no issues.

Pushed to master.

Thanks,
Tamar

gcc/ChangeLog:

	* emit-rtl.cc (validate_subreg): Relax subreg rule.

--- inline copy of patch -- 
diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc
index f6276a2d0b627fd5b2a742795a55423f449e9d93..ea85a46a0f014b81aeb76d69d19a57233dd70bdc 100644
--- a/gcc/emit-rtl.cc
+++ b/gcc/emit-rtl.cc
@@ -947,7 +947,7 @@ validate_subreg (machine_mode omode, machine_mode imode,
      in post-reload splitters that make arbitrarily mode changes to the
      registers themselves.  */
   else if (VECTOR_MODE_P (omode)
-	   && GET_MODE_INNER (omode) == GET_MODE_INNER (imode))
+	   && GET_MODE_UNIT_SIZE (omode) == GET_MODE_UNIT_SIZE (imode))
     ;
   /* Subregs involving floating point modes are not allowed to
      change size unless it's an insert into a complex mode.




-- 
-------------- next part --------------
diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc
index f6276a2d0b627fd5b2a742795a55423f449e9d93..ea85a46a0f014b81aeb76d69d19a57233dd70bdc 100644
--- a/gcc/emit-rtl.cc
+++ b/gcc/emit-rtl.cc
@@ -947,7 +947,7 @@ validate_subreg (machine_mode omode, machine_mode imode,
      in post-reload splitters that make arbitrarily mode changes to the
      registers themselves.  */
   else if (VECTOR_MODE_P (omode)
-	   && GET_MODE_INNER (omode) == GET_MODE_INNER (imode))
+	   && GET_MODE_UNIT_SIZE (omode) == GET_MODE_UNIT_SIZE (imode))
     ;
   /* Subregs involving floating point modes are not allowed to
      change size unless it's an insert into a complex mode.





More information about the Gcc-patches mailing list