Commit 4fc0c9c8 by Dominik Vogt Committed by Andreas Krebbel

Minor cleanup to allocate_dynamic_stack_space

gcc/ChangeLog:

2016-07-04  Dominik Vogt  <vogt@linux.vnet.ibm.com>
	    Jeff Law  <law@redhat.com>

	* explow.c (allocate_dynamic_stack_space): Simplify knowing that
	MUST_ALIGN was always true and extra_align ist always BITS_PER_UNIT.


Co-Authored-By: Jeff Law <law@redhat.com>

From-SVN: r237983
parent 430bb38e
2016-07-04 Dominik Vogt <vogt@linux.vnet.ibm.com>
Jeff Law <law@redhat.com>
* explow.c (allocate_dynamic_stack_space): Simplify knowing that
MUST_ALIGN was always true and extra_align ist always BITS_PER_UNIT.
2016-07-04 Yuri Rumyantsev <ysrumyan@gmail.com> 2016-07-04 Yuri Rumyantsev <ysrumyan@gmail.com>
* config/i386/i386.c (ix86_expand_vec_perm): Add handle one-operand * config/i386/i386.c (ix86_expand_vec_perm): Add handle one-operand
......
...@@ -1174,8 +1174,7 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align, ...@@ -1174,8 +1174,7 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align,
HOST_WIDE_INT stack_usage_size = -1; HOST_WIDE_INT stack_usage_size = -1;
rtx_code_label *final_label; rtx_code_label *final_label;
rtx final_target, target; rtx final_target, target;
unsigned extra_align = 0; unsigned extra;
bool must_align;
/* If we're asking for zero bytes, it doesn't matter what we point /* If we're asking for zero bytes, it doesn't matter what we point
to since we can't dereference it. But return a reasonable to since we can't dereference it. But return a reasonable
...@@ -1246,48 +1245,21 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align, ...@@ -1246,48 +1245,21 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align,
crtl->preferred_stack_boundary = PREFERRED_STACK_BOUNDARY; crtl->preferred_stack_boundary = PREFERRED_STACK_BOUNDARY;
/* We will need to ensure that the address we return is aligned to /* We will need to ensure that the address we return is aligned to
REQUIRED_ALIGN. If STACK_DYNAMIC_OFFSET is defined, we don't REQUIRED_ALIGN. At this point in the compilation, we don't always
always know its final value at this point in the compilation (it know the final value of the STACK_DYNAMIC_OFFSET used in function.c
might depend on the size of the outgoing parameter lists, for (it might depend on the size of the outgoing parameter lists, for
example), so we must align the value to be returned in that case. example), so we must preventively align the value. We leave space
(Note that STACK_DYNAMIC_OFFSET will have a default nonzero value if in SIZE for the hole that might result from the alignment operation. */
STACK_POINTER_OFFSET or ACCUMULATE_OUTGOING_ARGS are defined).
We must also do an alignment operation on the returned value if
the stack pointer alignment is less strict than REQUIRED_ALIGN.
If we have to align, we must leave space in SIZE for the hole
that might result from the alignment operation. */
must_align = (crtl->preferred_stack_boundary < required_align);
if (must_align)
{
if (required_align > PREFERRED_STACK_BOUNDARY)
extra_align = PREFERRED_STACK_BOUNDARY;
else if (required_align > STACK_BOUNDARY)
extra_align = STACK_BOUNDARY;
else
extra_align = BITS_PER_UNIT;
}
/* ??? STACK_POINTER_OFFSET is always defined now. */ extra = (required_align - BITS_PER_UNIT) / BITS_PER_UNIT;
#if defined (STACK_DYNAMIC_OFFSET) || defined (STACK_POINTER_OFFSET) size = plus_constant (Pmode, size, extra);
must_align = true; size = force_operand (size, NULL_RTX);
extra_align = BITS_PER_UNIT;
#endif
if (must_align)
{
unsigned extra = (required_align - extra_align) / BITS_PER_UNIT;
size = plus_constant (Pmode, size, extra); if (flag_stack_usage_info)
size = force_operand (size, NULL_RTX); stack_usage_size += extra;
if (flag_stack_usage_info)
stack_usage_size += extra;
if (extra && size_align > extra_align) if (extra && size_align > BITS_PER_UNIT)
size_align = extra_align; size_align = BITS_PER_UNIT;
}
/* Round the size to a multiple of the required stack alignment. /* Round the size to a multiple of the required stack alignment.
Since the stack if presumed to be rounded before this allocation, Since the stack if presumed to be rounded before this allocation,
...@@ -1361,13 +1333,10 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align, ...@@ -1361,13 +1333,10 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align,
if (MALLOC_ABI_ALIGNMENT >= required_align) if (MALLOC_ABI_ALIGNMENT >= required_align)
ask = size; ask = size;
else else
{ ask = expand_binop (Pmode, add_optab, size,
ask = expand_binop (Pmode, add_optab, size, gen_int_mode (required_align / BITS_PER_UNIT - 1,
gen_int_mode (required_align / BITS_PER_UNIT - 1, Pmode),
Pmode), NULL_RTX, 1, OPTAB_LIB_WIDEN);
NULL_RTX, 1, OPTAB_LIB_WIDEN);
must_align = true;
}
func = init_one_libfunc ("__morestack_allocate_stack_space"); func = init_one_libfunc ("__morestack_allocate_stack_space");
...@@ -1478,24 +1447,19 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align, ...@@ -1478,24 +1447,19 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align,
target = final_target; target = final_target;
} }
if (must_align) /* CEIL_DIV_EXPR needs to worry about the addition overflowing,
{ but we know it can't. So add ourselves and then do
/* CEIL_DIV_EXPR needs to worry about the addition overflowing, TRUNC_DIV_EXPR. */
but we know it can't. So add ourselves and then do target = expand_binop (Pmode, add_optab, target,
TRUNC_DIV_EXPR. */ gen_int_mode (required_align / BITS_PER_UNIT - 1,
target = expand_binop (Pmode, add_optab, target, Pmode),
gen_int_mode (required_align / BITS_PER_UNIT - 1, NULL_RTX, 1, OPTAB_LIB_WIDEN);
Pmode), target = expand_divmod (0, TRUNC_DIV_EXPR, Pmode, target,
NULL_RTX, 1, OPTAB_LIB_WIDEN); gen_int_mode (required_align / BITS_PER_UNIT, Pmode),
target = expand_divmod (0, TRUNC_DIV_EXPR, Pmode, target, NULL_RTX, 1);
gen_int_mode (required_align / BITS_PER_UNIT, target = expand_mult (Pmode, target,
Pmode), gen_int_mode (required_align / BITS_PER_UNIT, Pmode),
NULL_RTX, 1); NULL_RTX, 1);
target = expand_mult (Pmode, target,
gen_int_mode (required_align / BITS_PER_UNIT,
Pmode),
NULL_RTX, 1);
}
/* Now that we've committed to a return value, mark its alignment. */ /* Now that we've committed to a return value, mark its alignment. */
mark_reg_pointer (target, required_align); mark_reg_pointer (target, required_align);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment