This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 2/4] prologue and epilogue tidy and -mno-vrsave bug fix
- From: Alan Modra <amodra at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: David Edelsohn <dje dot gcc at gmail dot com>
- Date: Mon, 18 May 2015 12:24:34 +0930
- Subject: [PATCH 2/4] prologue and epilogue tidy and -mno-vrsave bug fix
- Authentication-results: sourceware.org; auth=none
This patch tidies the prologue and epilogue altivec code a little.
A number of places using info->altivec_size unnecessarily also test
TARGET_ALTIVEC_ABI, when rs6000_stack_info() guarantees that
info->altivec_size is zero if !TARGET_ALTIVEC_ABI.
Similarly by inspection of rs6000_stack_info() code,
TARGET_ALTIVEC_VRSAVE && info->vrsave_mask != 0, used when deciding to
save or restore vrsave, can be replaced with info->vrsave_size. I
also removed the TARGET_ALTIVEC test used with save/restore of vrsave.
I believe it is redundant because compute_vrsave_mask() will return 0
when no altivec registers are used (and of course you can't use then
without TARGET_ALTIVEC), except for Darwin where TARGET_ALTIVEC is
forced. The vrsave changes make the code actually doing the save or
restore visually consistent with code that sets up a frame register
for vrsave.
Finally, I've changed two places that use info->vrsave_mask to test
whether vrsave is saved or restored, to use info->vrsave_size. This
is a bug fix for -mno-vrsave.
* config/rs6000/rs6000.c (struct rs6000_stack): Correct comments.
(rs6000_stack_info): Don't zero offsets when not saving registers.
(debug_stack_info): Adjust to omit printing unused offsets,
as before.
(direct_return): Test vrsave_size rather than vrsave_mask.
(rs6000_emit_prologue): Likewise. Remove redundant altivec tests.
(rs6000_emit_epilogue): Likewise.
diff -urp gcc-stack-info1/gcc/config/rs6000/rs6000.c gcc-stack-info2/gcc/config/rs6000/rs6000.c
--- gcc-stack-info1/gcc/config/rs6000/rs6000.c 2015-05-18 09:44:34.027608414 +0930
+++ gcc-stack-info2/gcc/config/rs6000/rs6000.c 2015-05-16 13:33:37.170406399 +0930
@@ -155,10 +155,9 @@ typedef struct rs6000_stack {
int gp_size; /* size of saved GP registers */
int fp_size; /* size of saved FP registers */
int altivec_size; /* size of saved AltiVec registers */
- int cr_size; /* size to hold CR if not in save_size */
- int vrsave_size; /* size to hold VRSAVE if not in save_size */
- int altivec_padding_size; /* size of altivec alignment padding if
- not in save_size */
+ int cr_size; /* size to hold CR if not in fixed area */
+ int vrsave_size; /* size to hold VRSAVE */
+ int altivec_padding_size; /* size of altivec alignment padding */
int spe_gp_size; /* size of 64-bit GPR save size for SPE */
int spe_padding_size;
HOST_WIDE_INT total_size; /* total bytes allocated for stack */
@@ -5206,7 +5205,7 @@ direct_return (void)
&& info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1
&& ! info->lr_save_p
&& ! info->cr_save_p
- && info->vrsave_mask == 0
+ && info->vrsave_size == 0
&& ! info->push_p)
return 1;
}
@@ -23637,7 +23636,7 @@ rs6000_emit_prologue (void)
|| info->first_fp_reg_save < 64
|| info->first_gp_reg_save < 32
|| info->altivec_size != 0
- || info->vrsave_mask != 0
+ || info->vrsave_size != 0
|| crtl->calls_eh_return)
ptr_regno = 12;
else
@@ -24185,7 +24184,7 @@ rs6000_emit_prologue (void)
/* Save AltiVec registers if needed. Save here because the red zone does
not always include AltiVec registers. */
- if (!WORLD_SAVE_P (info) && TARGET_ALTIVEC_ABI
+ if (!WORLD_SAVE_P (info)
&& info->altivec_size != 0 && (strategy & SAVE_INLINE_VRS) == 0)
{
int end_save = info->altivec_save_offset + info->altivec_size;
@@ -24221,7 +24220,7 @@ rs6000_emit_prologue (void)
frame_off = ptr_off;
}
}
- else if (!WORLD_SAVE_P (info) && TARGET_ALTIVEC_ABI
+ else if (!WORLD_SAVE_P (info)
&& info->altivec_size != 0)
{
int i;
@@ -24263,9 +24262,7 @@ rs6000_emit_prologue (void)
epilogue. */
if (!WORLD_SAVE_P (info)
- && TARGET_ALTIVEC
- && TARGET_ALTIVEC_VRSAVE
- && info->vrsave_mask != 0)
+ && info->vrsave_size != 0)
{
rtx reg, vrsave;
int offset;
@@ -24827,8 +24824,7 @@ rs6000_emit_epilogue (int sibcall)
/* Restore AltiVec registers if we must do so before adjusting the
stack. */
- if (TARGET_ALTIVEC_ABI
- && info->altivec_size != 0
+ if (info->altivec_size != 0
&& (ALWAYS_RESTORE_ALTIVEC_BEFORE_POP
|| (DEFAULT_ABI != ABI_V4
&& offset_below_red_zone_p (info->altivec_save_offset))))
@@ -24915,9 +24911,7 @@ rs6000_emit_epilogue (int sibcall)
}
/* Restore VRSAVE if we must do so before adjusting the stack. */
- if (TARGET_ALTIVEC
- && TARGET_ALTIVEC_VRSAVE
- && info->vrsave_mask != 0
+ if (info->vrsave_size != 0
&& (ALWAYS_RESTORE_ALTIVEC_BEFORE_POP
|| (DEFAULT_ABI != ABI_V4
&& offset_below_red_zone_p (info->vrsave_save_offset))))
@@ -25011,7 +25005,6 @@ rs6000_emit_epilogue (int sibcall)
/* Restore AltiVec registers if we have not done so already. */
if (!ALWAYS_RESTORE_ALTIVEC_BEFORE_POP
- && TARGET_ALTIVEC_ABI
&& info->altivec_size != 0
&& (DEFAULT_ABI == ABI_V4
|| !offset_below_red_zone_p (info->altivec_save_offset)))
@@ -25119,9 +25112,7 @@ rs6000_emit_epilogue (int sibcall)
/* Restore VRSAVE if we have not done so already. */
if (!ALWAYS_RESTORE_ALTIVEC_BEFORE_POP
- && TARGET_ALTIVEC
- && TARGET_ALTIVEC_VRSAVE
- && info->vrsave_mask != 0
+ && info->vrsave_size != 0
&& (DEFAULT_ABI == ABI_V4
|| !offset_below_red_zone_p (info->vrsave_save_offset)))
{
--
Alan Modra
Australia Development Lab, IBM