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]

Re: [patch] Fix PR middle-end/22239 (take 2)


> Now we're back to new_reg being a PLUS, which is still wrong.
> You can, however, use force_operand to turn it into something
> that's a legitimate operand for a binop.

This version forces v->new_reg to a REG.  Tested on hppa-unknown-linux-gnu
and i686-linux-gnu with no regressions.

Ok for main?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.535
diff -u -3 -p -r1.535 loop.c
--- loop.c	7 Jul 2005 22:53:28 -0000	1.535
+++ loop.c	9 Jul 2005 19:13:13 -0000
@@ -5496,14 +5496,19 @@ loop_givs_rescan (struct loop *loop, str
 						  v->new_reg));
 	  else if (GET_CODE (*v->location) == PLUS
 		   && REG_P (XEXP (*v->location, 0))
-		   && REG_P (v->new_reg)
 		   && CONSTANT_P (XEXP (*v->location, 1)))
-	    loop_insn_emit_before (loop, 0, v->insn,
-				   gen_move_insn (XEXP (*v->location, 0),
-						  gen_rtx_MINUS
-						  (GET_MODE (*v->location),
-						   v->new_reg,
-						   XEXP (*v->location, 1))));
+	    {
+	      rtx reg, tem;
+	      start_sequence ();
+	      reg = force_reg (GET_MODE (*v->location), v->new_reg);
+	      tem = expand_simple_binop (GET_MODE (*v->location), MINUS,
+				         reg, XEXP (*v->location, 1),
+					 NULL_RTX, 0, OPTAB_LIB_WIDEN);
+	      emit_move_insn (XEXP (*v->location, 0), tem);
+	      tem = get_insns ();
+	      end_sequence ();
+	      loop_insn_emit_before (loop, 0, v->insn, tem);
+	    }
 	  else
 	    {
 	      /* If it wasn't a reg, create a pseudo and use that.  */


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