diff mbox

[SH] Add simple_return pattern

Message ID 504DF050.1070800@st.com
State New
Headers show

Commit Message

Christian Bruel Sept. 10, 2012, 1:51 p.m. UTC
This patch implements the simple_return pattern to enable -fshrink-wrap
on SH. It also clean up some redundancies for expand_epilogue (called
twice from the "return" and "epilogue" patterns and the
sh_expand_prologue parameter type.

No regressions with sh-superh-elf and sh4-linux gcc testsuites.

Thanks

Christian

Comments

Kaz Kojima Sept. 11, 2012, 1:05 a.m. UTC | #1
Christian Bruel <christian.bruel@st.com> wrote:
> This patch implements the simple_return pattern to enable -fshrink-wrap
> on SH. It also clean up some redundancies for expand_epilogue (called
> twice from the "return" and "epilogue" patterns and the
> sh_expand_prologue parameter type.
> 
> No regressions with sh-superh-elf and sh4-linux gcc testsuites.

With the patch + revision 191106, I've got a new failure:

FAIL: gcc.dg/tree-prof/bb-reorg.c compilation,  -fprofile-use -D_PROFILE_USE (internal compiler error)

for sh4-unknown-linux-gnu.  My testsuite/gcc/gcc.log says

/exp/ldroot/dodes/xsh-gcc/gcc/xgcc -B/exp/ldroot/dodes/xsh-gcc/gcc/ /exp/ldroot/dodes/LOCAL/trunk/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c -fno-diagnostics-show-caret -O2 -freorder-blocks-and-partition -fprofile-use -D_PROFILE_USE -lm -o /exp/ldroot/dodes/xsh-gcc/gcc/testsuite/gcc/bb-reorg.x02
/exp/ldroot/dodes/LOCAL/trunk/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c: In function 'main':
/exp/ldroot/dodes/LOCAL/trunk/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c:38:1: error: EDGE_CROSSING missing across section boundary
/exp/ldroot/dodes/LOCAL/trunk/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c:38:1: internal compiler error: verify_flow_info failed
Please submit a full bug report,

Regards,
	kaz
Christian Bruel Sept. 11, 2012, 7:56 a.m. UTC | #2
On 09/11/2012 03:05 AM, Kaz Kojima wrote:
> Christian Bruel <christian.bruel@st.com> wrote:
>> This patch implements the simple_return pattern to enable -fshrink-wrap
>> on SH. It also clean up some redundancies for expand_epilogue (called
>> twice from the "return" and "epilogue" patterns and the
>> sh_expand_prologue parameter type.
>>
>> No regressions with sh-superh-elf and sh4-linux gcc testsuites.
> 
> With the patch + revision 191106, I've got a new failure:
> 
> FAIL: gcc.dg/tree-prof/bb-reorg.c compilation,  -fprofile-use -D_PROFILE_USE (internal compiler error)
> 
> for sh4-unknown-linux-gnu.  My testsuite/gcc/gcc.log says
> 
> /exp/ldroot/dodes/xsh-gcc/gcc/xgcc -B/exp/ldroot/dodes/xsh-gcc/gcc/ /exp/ldroot/dodes/LOCAL/trunk/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c -fno-diagnostics-show-caret -O2 -freorder-blocks-and-partition -fprofile-use -D_PROFILE_USE -lm -o /exp/ldroot/dodes/xsh-gcc/gcc/testsuite/gcc/bb-reorg.x02
> /exp/ldroot/dodes/LOCAL/trunk/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c: In function 'main':
> /exp/ldroot/dodes/LOCAL/trunk/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c:38:1: error: EDGE_CROSSING missing across section boundary
> /exp/ldroot/dodes/LOCAL/trunk/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c:38:1: internal compiler error: verify_flow_info failed
> Please submit a full bug report,
> 
> Regards,

Ugh, indeed, I forgot a SPEC file that set the release mode on my
SH-Linux distri, so verify_flow_info was not called :-(. I need to test
again.

thanks !

Christian

> 	kaz
>
diff mbox

Patch

2012-08-29  Christian Bruel  <christian.bruel@st.com>

	* config/sh/sh-protos.h (sh_need_epilogue): Delete.
	* config/sh/sh.c (sh_need_epilogue): Delete.
	(sh_need_epilogue_known): Delete.
	(sh_output_function_epilogue): Remove sh_need_epilogue_known.
	* config/sh/sh.md (any_return): New iterator and optab.
	(simple_return): Define.
	(return): Check epilogue_completed.
	(epilogue): Use inline return rtl.
	(sh_expand_epilogue): Cleanup parameters boolean type.

Index: gcc/config/sh/sh-protos.h
===================================================================
--- gcc/config/sh/sh-protos.h	(revision 191129)
+++ gcc/config/sh/sh-protos.h	(working copy)
@@ -117,7 +117,6 @@ 
 extern int sh_media_register_for_return (void);
 extern void sh_expand_prologue (void);
 extern void sh_expand_epilogue (bool);
-extern bool sh_need_epilogue (void);
 extern void sh_set_return_address (rtx, rtx);
 extern int initial_elimination_offset (int, int);
 extern bool fldi_ok (void);
Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c	(revision 191129)
+++ gcc/config/sh/sh.c	(working copy)
@@ -7901,22 +7901,6 @@ 
 
 static int sh_need_epilogue_known = 0;
 
-bool
-sh_need_epilogue (void)
-{
-  if (! sh_need_epilogue_known)
-    {
-      rtx epilogue;
-
-      start_sequence ();
-      sh_expand_epilogue (0);
-      epilogue = get_insns ();
-      end_sequence ();
-      sh_need_epilogue_known = (epilogue == NULL ? -1 : 1);
-    }
-  return sh_need_epilogue_known > 0;
-}
-
 /* Emit code to change the current function's return address to RA.
    TEMP is available as a scratch register, if needed.  */
 
@@ -7996,7 +7980,6 @@ 
 sh_output_function_epilogue (FILE *file ATTRIBUTE_UNUSED,
 			     HOST_WIDE_INT size ATTRIBUTE_UNUSED)
 {
-  sh_need_epilogue_known = 0;
 }
 
 static rtx
Index: gcc/config/sh/sh.md
===================================================================
--- gcc/config/sh/sh.md	(revision 191129)
+++ gcc/config/sh/sh.md	(working copy)
@@ -177,6 +177,10 @@ 
   (UNSPECV_EH_RETURN	12)
 ])
 
+(define_code_iterator any_return [return simple_return])
+(define_code_attr optab [(return "return")
+			 (simple_return "simple_return")])
+
 ;; -------------------------------------------------------------------------
 ;; Attributes
 ;; -------------------------------------------------------------------------
@@ -9280,7 +9284,7 @@ 
   [(return)]
   ""
 {
-  sh_expand_epilogue (1);
+  sh_expand_epilogue (true);
   if (TARGET_SHCOMPACT)
     {
       rtx insn, set;
@@ -10099,9 +10103,13 @@ 
 }
   [(set_attr "type" "load_media")])
 
+(define_expand "simple_return"
+  [(simple_return)]
+ "")
+
 (define_expand "return"
-  [(return)]
-  "reload_completed && ! sh_need_epilogue ()"
+  [(simple_return)]
+ "reload_completed && epilogue_completed"
 {
   if (TARGET_SHMEDIA)
     {
@@ -10117,8 +10125,8 @@ 
     }
 })
 
-(define_insn "*return_i"
-  [(return)]
+(define_insn "*<optab>_i"
+  [(any_return)]
   "TARGET_SH1 && ! (TARGET_SHCOMPACT
 		    && (crtl->args.info.call_cookie
 			& CALL_COOKIE_RET_TRAMP (1)))
@@ -10244,19 +10252,12 @@ 
 (define_expand "prologue"
   [(const_int 0)]
   ""
-{
-  sh_expand_prologue ();
-  DONE;
-})
+  "sh_expand_prologue (); DONE;")
 
 (define_expand "epilogue"
   [(return)]
   ""
-{
-  sh_expand_epilogue (0);
-  emit_jump_insn (gen_return ());
-  DONE;
-})
+  "sh_expand_epilogue (false);")
 
 (define_expand "eh_return"
   [(use (match_operand 0 "register_operand" ""))]