This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix alloca with SUPPORTS_STACK_ALIGNMENT (PR middle-end/45234)
On 09/23/2010 03:15 PM, Jakub Jelinek wrote:
> round_push (rtx size)
> {
> - int align = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT;
> + int align;
> +
> + if (crtl->preferred_stack_boundary < MAX_SUPPORTED_STACK_ALIGNMENT)
> + {
> + /* CEIL_DIV_EXPR needs to worry about the addition overflowing,
> + but we know it can't. So add ourselves and then do
> + TRUNC_DIV_EXPR. */
> + rtx alignm1 = plus_constant (virtual_preferred_stack_boundary_rtx, -1);
> + alignm1 = force_operand (alignm1, NULL_RTX);
> + size = expand_binop (Pmode, add_optab, size, alignm1,
> + NULL_RTX, 1, OPTAB_LIB_WIDEN);
> + size = expand_divmod (0, TRUNC_DIV_EXPR, Pmode, size,
> + virtual_preferred_stack_boundary_rtx,
> + NULL_RTX, 1);
> + size = expand_mult (Pmode, size, virtual_preferred_stack_boundary_rtx,
> + NULL_RTX, 1);
> + return size;
> + }
It seems like it would be better to share code with the existing
expand_binop path here.
Otherwise this looks good.
r~