diff mbox series

PR101260 regcprop: Add mode change check for copy reg

Message ID 20220121165222.57530-1-krebbel@linux.ibm.com
State New
Headers show
Series PR101260 regcprop: Add mode change check for copy reg | expand

Commit Message

Andreas Krebbel Jan. 21, 2022, 4:52 p.m. UTC
When propagating a multi-word register into an access with a smaller
mode the can_change_mode backend hook is already consulted for the
original register.  This however is also required for the intermediate
copy in copy_regno which might use a different register class.

Bootstrapped on x86_64 and s390x. No testsuite regressions.

Ok for mainline?

gcc/ChangeLog:

	PR rtl-optimization/101260
	* regcprop.cc (maybe_mode_change): Invoke mode_change_ok also for
	copy_regno.
---
 gcc/regcprop.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jeff Law Jan. 28, 2022, 6:48 p.m. UTC | #1
On 1/21/2022 9:52 AM, Andreas Krebbel via Gcc-patches wrote:
> When propagating a multi-word register into an access with a smaller
> mode the can_change_mode backend hook is already consulted for the
> original register.  This however is also required for the intermediate
> copy in copy_regno which might use a different register class.
>
> Bootstrapped on x86_64 and s390x. No testsuite regressions.
>
> Ok for mainline?
>
> gcc/ChangeLog:
>
> 	PR rtl-optimization/101260
> 	* regcprop.cc (maybe_mode_change): Invoke mode_change_ok also for
> 	copy_regno.
I'd been sitting on Stefan's patch because it just didn't feel right, 
but I also knew I'd need to dig further into it to either resolve my 
concerns or be able to express them clearly to Stefan.

I like this patch much better :-)  OK for the trunk.  Bonus points if 
you pick up Stefan's testcase from way back in October.

Jeff
diff mbox series

Patch

diff --git a/gcc/regcprop.cc b/gcc/regcprop.cc
index 1a9bcf0a1ad..8e966f2b5ac 100644
--- a/gcc/regcprop.cc
+++ b/gcc/regcprop.cc
@@ -426,7 +426,8 @@  maybe_mode_change (machine_mode orig_mode, machine_mode copy_mode,
 
   if (orig_mode == new_mode)
     return gen_raw_REG (new_mode, regno);
-  else if (mode_change_ok (orig_mode, new_mode, regno))
+  else if (mode_change_ok (orig_mode, new_mode, regno)
+	   && mode_change_ok (copy_mode, new_mode, copy_regno))
     {
       int copy_nregs = hard_regno_nregs (copy_regno, copy_mode);
       int use_nregs = hard_regno_nregs (copy_regno, new_mode);