This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Don't let the old loop optimizer stomp on hard regs


loop.c inserts temporaries by using replace_regs, which says quite clearly
that hard registers should not be mapped to pseudos or vice versa.  This
patch adjust the insert_temp check to not try this for hard registers.
Without this patch, loop will replace (set (reg:SI 0) (unspec)) with
(set (reg:SI pseudo) (unspec)), which may be unrecognizable: for example,
arm.md:load_tp_soft.

Tested on arm-none-linux-gnueabi.  OK to commit?

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-11-14  Daniel Jacobowitz  <dan@codesourcery.com>

	* loop.c (scan_loop): Do not insert temporaries for hard registers.

Index: gcc/gcc/loop.c
===================================================================
--- gcc.orig/gcc/loop.c	2005-11-03 15:16:20.000000000 -0500
+++ gcc/gcc/loop.c	2005-11-08 09:20:14.000000000 -0500
@@ -1238,13 +1238,15 @@ scan_loop (struct loop *loop, int flags)
 		 - with -Os (this certainly increases size),
 		 - if the mode doesn't support copy operations (obviously),
 		 - if the source is already a reg (the motion will gain nothing),
-		 - if the source is a legitimate constant (likewise).  */
+		 - if the source is a legitimate constant (likewise),
+	         - if the dest is a hard register (may be unrecognizable).  */
 	      else if (insert_temp
 		       && (optimize_size
 			   || ! can_copy_p (GET_MODE (SET_SRC (set)))
 			   || REG_P (SET_SRC (set))
 			   || (CONSTANT_P (SET_SRC (set))
-			       && LEGITIMATE_CONSTANT_P (SET_SRC (set)))))
+			       && LEGITIMATE_CONSTANT_P (SET_SRC (set)))
+			   || REGNO (SET_DEST (set)) < FIRST_PSEUDO_REGISTER))
 		;
 	      else if ((tem = loop_invariant_p (loop, src))
 		       && (dependencies == 0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]