diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a582c5fce7b98878c37e5cdaa80f4b0d8370f4d0..5fc7710842f6c839a20a6f7ec2f6f96042703398 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,19 @@
+2007-09-18  Rask Ingemann Lambertsen  <rask@sygehus.dk>
+
+	PR target/33388
+	PR target/33397
+	* config/fr30/fr30.md (addsi3): Check REG_P() before calling REGNO().
+	(addsi_small_int): Likewise.
+	(addsi_big_int): Use rtx_equal_p() instead of REGNO() comparison.
+	(one_cmplsi2): Likewise.
+	(negsi2): Delete.
+	(enter_func): Expand insn using hard_frame_pointer_rtx and
+	stack_pointer_rtx.
+	(*enter_func): New.
+	* config/fr30/fr30.c (fr30_expand_prologue): Check for
+	hard_frame_pointer_rtx instead of using REGNO() check.
+	Properly sign extend GEN_INT() argument.
+
 2007-09-18  Roman Zippel <zippel@linux-m68k.org>
 
 	* config/m68k/m68k.c (override_options): Remove USE_GAS,
diff --git a/gcc/config/fr30/fr30.c b/gcc/config/fr30/fr30.c
index 7856f879090d8d5b740ca66096e09e27f68b2c47..343dd02ba09d48c66408d43a11f5ec687054d95e 100644
--- a/gcc/config/fr30/fr30.c
+++ b/gcc/config/fr30/fr30.c
@@ -308,7 +308,7 @@ fr30_expand_prologue (void)
 		     G++ testsuite.  */
 		  if (! frame_pointer_needed
 		      && GET_CODE (part) == SET
-		      && REGNO (SET_DEST (part)) == HARD_FRAME_POINTER_REGNUM)
+		      && SET_DEST (part) == hard_frame_pointer_rtx)
 		    RTX_FRAME_RELATED_P (part) = 0;
 		  else
 		    RTX_FRAME_RELATED_P (part) = 1;
@@ -336,7 +336,8 @@ fr30_expand_prologue (void)
     ; /* Nothing to do.  */
   else if (current_frame_info.frame_size <= 512)
     {
-      insn = emit_insn (gen_add_to_stack (GEN_INT (- current_frame_info.frame_size)));
+      insn = emit_insn (gen_add_to_stack
+			 (GEN_INT (- (signed) current_frame_info.frame_size)));
       RTX_FRAME_RELATED_P (insn) = 1;
     }
   else
diff --git a/gcc/config/fr30/fr30.md b/gcc/config/fr30/fr30.md
index 8bd0c35ef37d9ee5b424f33264d3dfd152d75be2..a198ea3544dbadcfc84d6f497ccd21441070e55a 100644
--- a/gcc/config/fr30/fr30.md
+++ b/gcc/config/fr30/fr30.md
@@ -660,7 +660,8 @@
     emit_insn (gen_addsi_big_int (operands[0], operands[1], operands[2]));
   else if (INTVAL (operands[2]) >= -16
 	   && INTVAL (operands[2]) <= 15
-	   && (!REGNO_PTR_FRAME_P (REGNO (operands[1]))
+	   && (!REG_P (operands[1])
+	       || !REGNO_PTR_FRAME_P (REGNO (operands[1]))
 	       || REGNO (operands[1]) == STACK_POINTER_REGNUM))
     emit_insn (gen_addsi_small_int (operands[0], operands[1], operands[2]));
   else
@@ -684,7 +685,8 @@
   [(set (match_operand:SI 0 "register_operand"              "=r,r")
 	(plus:SI (match_operand:SI 1 "register_operand"      "0,0")
 		 (match_operand:SI 2 "add_immediate_operand" "I,J")))]
-  "! REGNO_PTR_FRAME_P (REGNO (operands[1]))
+  "!REG_P (operands[1])
+   || !REGNO_PTR_FRAME_P (REGNO (operands[1]))
    || REGNO (operands[1]) == STACK_POINTER_REGNUM"
   "@
    addn	%2, %0
@@ -698,7 +700,7 @@
   ""
   "{
   /* Cope with the possibility that ops 0 and 1 are the same register.  */
-  if (REGNO (operands[0]) == REGNO (operands[1]))
+  if (rtx_equal_p (operands[0], operands[1]))
     {
       if (reload_in_progress || reload_completed)
         {
@@ -804,43 +806,6 @@
 )
 
 ;;}}}
-;;{{{ Negation 
-
-(define_expand "negsi2"
-  [(set (match_operand:SI 0 "register_operand"         "")
-	(neg:SI (match_operand:SI 1 "register_operand" "")))]
-  ""
-  "{
-  if (REGNO (operands[0]) == REGNO (operands[1]))
-    {
-      if (reload_in_progress || reload_completed)
-        {
-	  rtx reg = gen_rtx_REG (SImode, 0/*COMPILER_SCRATCH_REGISTER*/);
-	  
-	  emit_insn (gen_movsi (reg, const0_rtx));
-	  emit_insn (gen_subsi3 (reg, reg, operands[0]));
-	  emit_insn (gen_movsi (operands[0], reg));
-	}
-      else
-	{
-	  rtx reg = gen_reg_rtx (SImode);
-	
-	  emit_insn (gen_movsi (reg, const0_rtx));
-	  emit_insn (gen_subsi3 (reg, reg, operands[0]));
-	  emit_insn (gen_movsi (operands[0], reg));
-	}
-    }
-  else
-    {
-      emit_insn (gen_movsi_internal (operands[0], const0_rtx));
-      emit_insn (gen_subsi3 (operands[0], operands[0], operands[1]));
-    }
-  DONE;
-  }"
-)
-
-;;}}}
-
 ;;}}} 
 ;;{{{ Shifts 
 
@@ -922,7 +887,7 @@
 	(not:SI (match_operand:SI 1 "register_operand" "")))]
   ""
   "{
-  if (REGNO (operands[0]) == REGNO (operands[1]))
+  if (rtx_equal_p (operands[0], operands[1]))
     {
       if (reload_in_progress || reload_completed)
         {
@@ -1406,7 +1371,25 @@
   "leave"
 )
 
-(define_insn "enter_func"
+(define_expand "enter_func"
+  [(parallel
+  [(set:SI (mem:SI (minus:SI (match_dup 1)
+			     (const_int 4)))
+	   (match_dup 2))
+   (set:SI (match_dup 2)
+	   (minus:SI (match_dup 1)
+		     (const_int 4)))
+   (set:SI (match_dup 1)
+	   (minus:SI (match_dup 1)
+		     (match_operand:SI 0 "immediate_operand")))]
+  )]
+  ""
+{
+  operands[1] = stack_pointer_rtx;
+  operands[2] = hard_frame_pointer_rtx;
+})
+
+(define_insn "*enter_func"
   [(set:SI (mem:SI (minus:SI (reg:SI 15)
 			     (const_int 4)))
 	   (reg:SI 14))