[PATCH,rs6000] fix bugs with out-of-line prologues/epilogues
Nathan Froyd
froydnj@codesourcery.com
Fri Oct 31 19:59:00 GMT 2008
The patch below fixes a few problems with out-of-line prologues and
epilogues. The first thing I noticed was that no_global_regs_above had
an operator precedence problem that caused it to return 'false' way more
often than it needed to. I fixed that, and then fixed the two
regressions that turned up from that:
* We were using the wrong logic in rs6000_emit_prologue when consulting
call_used_regs to determine if the static chain was in use;
* regrename would sometimes reach into the RTL we produced to describe
the calls to out-of-line prologues/epilogues and rename r11. This has
the effect of turning the working code:
addi r11, r1, X
b _restgpr_Y_x
into:
addi r6, r1, X # as an example
b _restgpr_Y_x
and since r11 never got setup for _restgpr_Y_x, things would fall
over. I fixed this by using an explicit (reg:P 11) in the machine
descriptions for out-of-line prologues/epilogues, but it's not
entirely obvious to me that this is a bulletproof fix.
Regtested on powerpc-linux-gnuspe. OK to commit?
-Nathan
2008-10-31 Nathan Froyd <froydnj@codesourcery.com>
* config/rs6000/rs6000.c (no_global_regs_above): Fix precedence
problem.
(rs6000_emit_prologue): Invert logic.
* config/rs6000/rs6000.md (*save_gpregs_<mode>): Use explicit
(reg:P 11) instead of match_operand.
(*save_fpregs_<mode>): Likewise.
(*restore_gpregs_<mode>): Likewise.
(*return_and_restore_gpregs_<mode>): Likewise.
(*return_and_restore_fpregs_<mode>): Likewise.
* config/rs6000/spe.md (*save_gpregs_spe): Use explicit
(reg:P 11) insted of match_operand.
(*restore_gpregs_spe): Likewise.
(*return_and_restore_gpregs_spe): Likewise.
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c (revision 141484)
+++ gcc/config/rs6000/rs6000.c (working copy)
@@ -15839,7 +15839,8 @@ static bool
no_global_regs_above (int first, bool gpr)
{
int i;
- for (i = first; i < gpr ? 32 : 64 ; i++)
+ int last = gpr ? 32 : 64;
+ for (i = first; i < last; i++)
if (global_regs[i])
return false;
return true;
@@ -16118,7 +16119,7 @@ rs6000_emit_prologue (void)
int using_store_multiple;
int using_static_chain_p = (cfun->static_chain_decl != NULL_TREE
&& df_regs_ever_live_p (STATIC_CHAIN_REGNUM)
- && !call_used_regs[STATIC_CHAIN_REGNUM]);
+ && call_used_regs[STATIC_CHAIN_REGNUM]);
HOST_WIDE_INT sp_offset = 0;
if (TARGET_FIX_AND_CONTINUE)
Index: gcc/config/rs6000/rs6000.md
===================================================================
--- gcc/config/rs6000/rs6000.md (revision 141484)
+++ gcc/config/rs6000/rs6000.md (working copy)
@@ -14604,9 +14604,9 @@ (define_insn "*save_gpregs_<mode>"
[(match_parallel 0 "any_parallel_operand"
[(clobber (reg:P 65))
(use (match_operand:P 1 "symbol_ref_operand" "s"))
- (use (match_operand:P 2 "gpc_reg_operand" "r"))
- (set (match_operand:P 3 "memory_operand" "=m")
- (match_operand:P 4 "gpc_reg_operand" "r"))])]
+ (use (reg:P 11))
+ (set (match_operand:P 2 "memory_operand" "=m")
+ (match_operand:P 3 "gpc_reg_operand" "r"))])]
""
"bl %z1"
[(set_attr "type" "branch")
@@ -14616,9 +14616,9 @@ (define_insn "*save_fpregs_<mode>"
[(match_parallel 0 "any_parallel_operand"
[(clobber (reg:P 65))
(use (match_operand:P 1 "symbol_ref_operand" "s"))
- (use (match_operand:P 2 "gpc_reg_operand" "r"))
- (set (match_operand:DF 3 "memory_operand" "=m")
- (match_operand:DF 4 "gpc_reg_operand" "f"))])]
+ (use (reg:P 11))
+ (set (match_operand:DF 2 "memory_operand" "=m")
+ (match_operand:DF 3 "gpc_reg_operand" "f"))])]
""
"bl %z1"
[(set_attr "type" "branch")
@@ -14711,9 +14711,9 @@ (define_insn "*restore_gpregs_<mode>"
[(match_parallel 0 "any_parallel_operand"
[(clobber (match_operand:P 1 "register_operand" "=l"))
(use (match_operand:P 2 "symbol_ref_operand" "s"))
- (use (match_operand:P 3 "gpc_reg_operand" "r"))
- (set (match_operand:P 4 "gpc_reg_operand" "=r")
- (match_operand:P 5 "memory_operand" "m"))])]
+ (use (reg:P 11))
+ (set (match_operand:P 3 "gpc_reg_operand" "=r")
+ (match_operand:P 4 "memory_operand" "m"))])]
""
"bl %z2"
[(set_attr "type" "branch")
@@ -14724,9 +14724,9 @@ (define_insn "*return_and_restore_gpregs
[(return)
(clobber (match_operand:P 1 "register_operand" "=l"))
(use (match_operand:P 2 "symbol_ref_operand" "s"))
- (use (match_operand:P 3 "gpc_reg_operand" "r"))
- (set (match_operand:P 4 "gpc_reg_operand" "=r")
- (match_operand:P 5 "memory_operand" "m"))])]
+ (use (reg:P 11))
+ (set (match_operand:P 3 "gpc_reg_operand" "=r")
+ (match_operand:P 4 "memory_operand" "m"))])]
""
"b %z2"
[(set_attr "type" "branch")
@@ -14737,9 +14737,9 @@ (define_insn "*return_and_restore_fpregs
[(return)
(clobber (match_operand:P 1 "register_operand" "=l"))
(use (match_operand:P 2 "symbol_ref_operand" "s"))
- (use (match_operand:P 3 "gpc_reg_operand" "r"))
- (set (match_operand:DF 4 "gpc_reg_operand" "=f")
- (match_operand:DF 5 "memory_operand" "m"))])]
+ (use (reg:P 11))
+ (set (match_operand:DF 3 "gpc_reg_operand" "=f")
+ (match_operand:DF 4 "memory_operand" "m"))])]
""
"b %z2"
[(set_attr "type" "branch")
Index: gcc/config/rs6000/spe.md
===================================================================
--- gcc/config/rs6000/spe.md (revision 141484)
+++ gcc/config/rs6000/spe.md (working copy)
@@ -3144,9 +3144,9 @@ (define_insn "*save_gpregs_spe"
[(match_parallel 0 "any_parallel_operand"
[(clobber (reg:P 65))
(use (match_operand:P 1 "symbol_ref_operand" "s"))
- (use (match_operand:P 2 "gpc_reg_operand" "r"))
- (set (match_operand:V2SI 3 "memory_operand" "=m")
- (match_operand:V2SI 4 "gpc_reg_operand" "r"))])]
+ (use (reg:P 11))
+ (set (match_operand:V2SI 2 "memory_operand" "=m")
+ (match_operand:V2SI 3 "gpc_reg_operand" "r"))])]
"TARGET_SPE_ABI"
"bl %z1"
[(set_attr "type" "branch")
@@ -3156,9 +3156,9 @@ (define_insn "*restore_gpregs_spe"
[(match_parallel 0 "any_parallel_operand"
[(clobber (reg:P 65))
(use (match_operand:P 1 "symbol_ref_operand" "s"))
- (use (match_operand:P 2 "gpc_reg_operand" "r"))
- (set (match_operand:V2SI 3 "gpc_reg_operand" "=r")
- (match_operand:V2SI 4 "memory_operand" "m"))])]
+ (use (reg:P 11))
+ (set (match_operand:V2SI 2 "gpc_reg_operand" "=r")
+ (match_operand:V2SI 3 "memory_operand" "m"))])]
"TARGET_SPE_ABI"
"bl %z1"
[(set_attr "type" "branch")
@@ -3169,9 +3169,9 @@ (define_insn "*return_and_restore_gpregs
[(return)
(clobber (reg:P 65))
(use (match_operand:P 1 "symbol_ref_operand" "s"))
- (use (match_operand:P 2 "gpc_reg_operand" "r"))
- (set (match_operand:V2SI 3 "gpc_reg_operand" "=r")
- (match_operand:V2SI 4 "memory_operand" "m"))])]
+ (use (reg:P 11))
+ (set (match_operand:V2SI 2 "gpc_reg_operand" "=r")
+ (match_operand:V2SI 3 "memory_operand" "m"))])]
"TARGET_SPE_ABI"
"b %z1"
[(set_attr "type" "branch")
More information about the Gcc-patches
mailing list