[PATCH][RFC] target/61810 - disable init-regs pass on targets using LRA

Richard Biener rguenther@suse.de
Wed Aug 11 14:33:15 GMT 2021

This patch disables the init-regs pass on targets using LRA.
It's not clear as to what issue the init-regs papers over and
most definitely LRA should get it right.  This leaves targets
still using reload unaffected but will expose any such LRA
bug if it exists, allowing it to be identified and fixed.

The change can cause testsuite fallout since the explicit
initializations can have an effect on passes like combine.
For example on x86_64 this results in

+FAIL: gcc.target/i386/extract-insert-combining.c scan-assembler-times (?:vmovd|
movd)[ \\\\t]+[^{\\n]*%xmm[0-9] 3
+FAIL: gcc.target/i386/extract-insert-combining.c scan-assembler-times (?:vpinsr
d|pinsrd)[ \\\\t]+[^{\\n]*%xmm[0-9] 1

it also results in yet unanalyzed

+FAIL: gnat.dg/sso8.adb execution test

I welcome trying this change on other architectures, like
for example 'arm' that's singled out in the init-regs comments
as affected architecture.

Bootstrapped and tested on x86_64-unknown-linux-gnu with all languages
and {,-m32} with the above remaining fallout (I fixed another
testism already).

2021-08-11  Richard Biener  <rguenther@suse.de>

	PR target/61810
	* init-regs.c (pass_initialize_regs::gate): Gate on
	targetm.lra_p ().
 gcc/init-regs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/init-regs.c b/gcc/init-regs.c
index 72e898f3e33..8f038f54fff 100644
--- a/gcc/init-regs.c
+++ b/gcc/init-regs.c
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "memmodel.h"
 #include "emit-rtl.h"
 #include "expr.h"
+#include "target.h"
 #include "tree-pass.h"
 /* Check all of the uses of pseudo variables.  If any use that is MUST
@@ -153,7 +154,7 @@ public:
   /* opt_pass methods: */
-  virtual bool gate (function *) { return optimize > 0; }
+  virtual bool gate (function *) { return optimize > 0 && !targetm.lra_p (); }
   virtual unsigned int execute (function *)
       initialize_uninitialized_regs ();

More information about the Gcc-patches mailing list