Message ID | 20160726155317.GA5718@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
On 07/26/2016 09:53 AM, Dominik Vogt wrote: > Finally a patch that works and is simple. Bootstrapped and > regression tested on s390, s390x biarch and x86_64. The new patch > exploits the known alignment of (stack pointer + > STACK_DYNAMIC_OFFSET) as described earlier (see below). I think > that is the right way to get rid of the extra allocation. It > took a long time to understand the problem. > > As the patch triggers a bug in the fortran compiler, the > der_type.f90 test case may fail on some targets if this patch is > used without the fortran fix that I've posted in another thread. > > (The patch also contains a fix for a typo in a comment in the > patched function.) > > See ChangeLog for a full description of the new patch. > > Since the patch is all new, we're not going to commit it without a > new OK. I like this one much better :-) OK. Thanks for your patience, JEff
> gcc/ChangeLog > > * explow.c (get_dynamic_stack_size): Take known alignment of stack > pointer + STACK_DYNAMIC_OFFSET into account when calculating the size > needed. > Correct a typo in a comment. Applied. Thanks! -Andreas-
diff --git a/gcc/explow.c b/gcc/explow.c index a345690..f97a214 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -1224,9 +1224,15 @@ get_dynamic_stack_size (rtx *psize, unsigned size_align, example), so we must preventively align the value. We leave space in SIZE for the hole that might result from the alignment operation. */ - extra = (required_align - BITS_PER_UNIT) / BITS_PER_UNIT; - size = plus_constant (Pmode, size, extra); - size = force_operand (size, NULL_RTX); + unsigned known_align = REGNO_POINTER_ALIGN (VIRTUAL_STACK_DYNAMIC_REGNUM); + if (known_align == 0) + known_align = BITS_PER_UNIT; + if (required_align > known_align) + { + extra = (required_align - known_align) / BITS_PER_UNIT; + size = plus_constant (Pmode, size, extra); + size = force_operand (size, NULL_RTX); + } if (flag_stack_usage_info && pstack_usage_size) *pstack_usage_size += extra; @@ -1235,7 +1241,7 @@ get_dynamic_stack_size (rtx *psize, unsigned size_align, size_align = BITS_PER_UNIT; /* 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 is presumed to be rounded before this allocation, this will maintain the required alignment. If the stack grows downward, we could save an insn by subtracting