[1/2] configure: Automatically enable local_aligned_8/16 if we've got an aligned stack

Message ID 1310921852-99993-1-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö July 17, 2011, 4:57 p.m.
---
 configure |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

Comments

Mans Rullgard July 17, 2011, 5:21 p.m. | #1
Martin Storsjö <martin@martin.st> writes:

> ---
>  configure |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/configure b/configure
> index 28e3e25..40a93cd 100755
> --- a/configure
> +++ b/configure
> @@ -1227,8 +1227,10 @@ avx_deps="ssse3"
>  aligned_stack_if_any="ppc x86"
>  fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
>  fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
>  fast_unaligned_if_any="armv6 ppc x86"
> +local_aligned_8_if="aligned_stack"
> +local_aligned_16_if="aligned_stack"
>
>  need_memalign="altivec neon sse"
>  inline_asm_deps="!tms470"
>
> @@ -2629,10 +2631,8 @@ elif enabled mips; then
>      enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
>
>  elif enabled ppc; then
>
> -    enable local_aligned_8 local_aligned_16
> -
>      check_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
>      check_asm ibm_asm   '"add 0, 0, 0"'
>      check_asm ppc4xx    '"maclhw r10, r11, r12"'
>      check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
> @@ -2667,10 +2667,8 @@ elif enabled sparc; then
>          add_cflags -mcpu=ultrasparc -mtune=ultrasparc
>
>  elif enabled x86; then
>
> -    enable local_aligned_8 local_aligned_16
> -
>      # check whether EBP is available on x86
>      # As 'i' is stored on the stack, this program will crash
>      # if the base pointer is used to access it because the
>      # base pointer is cleared in the inline assembly code.
> -- 

This is wrong.  ALIGNED_STACK is supposed to be set if the stack really
is aligned to maximum required by any instruction.  LOCAL_ALIGNED_*
should be set if the compiler supports aligning variables on the stack
to 8/16 bytes by any means, which is sometimes possible even if the
stack is not aligned on entry.  For example, some setups with icc do not
have aligned stack but still support explicitly aligning variables.

Please only add the _deps and add aligned_stack to CMDLINE_SELECT.  That
will provide a means of disabling those settings without altering the
semantics when left automatic.
Mans Rullgard July 17, 2011, 5:23 p.m. | #2
Måns Rullgård <mans@mansr.com> writes:

> Martin Storsjö <martin@martin.st> writes:
>
>> ---
>>  configure |    6 ++----
>>  1 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 28e3e25..40a93cd 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1227,8 +1227,10 @@ avx_deps="ssse3"
>>  aligned_stack_if_any="ppc x86"
>>  fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
>>  fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
>>  fast_unaligned_if_any="armv6 ppc x86"
>> +local_aligned_8_if="aligned_stack"
>> +local_aligned_16_if="aligned_stack"
>>
>>  need_memalign="altivec neon sse"
>>  inline_asm_deps="!tms470"
>>
>> @@ -2629,10 +2631,8 @@ elif enabled mips; then
>>      enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
>>
>>  elif enabled ppc; then
>>
>> -    enable local_aligned_8 local_aligned_16
>> -
>>      check_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
>>      check_asm ibm_asm   '"add 0, 0, 0"'
>>      check_asm ppc4xx    '"maclhw r10, r11, r12"'
>>      check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
>> @@ -2667,10 +2667,8 @@ elif enabled sparc; then
>>          add_cflags -mcpu=ultrasparc -mtune=ultrasparc
>>
>>  elif enabled x86; then
>>
>> -    enable local_aligned_8 local_aligned_16
>> -
>>      # check whether EBP is available on x86
>>      # As 'i' is stored on the stack, this program will crash
>>      # if the base pointer is used to access it because the
>>      # base pointer is cleared in the inline assembly code.
>> -- 
>
> This is wrong.  ALIGNED_STACK is supposed to be set if the stack really
> is aligned to maximum required by any instruction.  LOCAL_ALIGNED_*
> should be set if the compiler supports aligning variables on the stack
> to 8/16 bytes by any means, which is sometimes possible even if the
> stack is not aligned on entry.  For example, some setups with icc do not
> have aligned stack but still support explicitly aligning variables.
>
> Please only add the _deps and add aligned_stack to CMDLINE_SELECT.  That
> will provide a means of disabling those settings without altering the
> semantics when left automatic.

Sorry, that's still wrong.  x86 sucks.

Patch

diff --git a/configure b/configure
index 28e3e25..40a93cd 100755
--- a/configure
+++ b/configure
@@ -1227,8 +1227,10 @@  avx_deps="ssse3"
 aligned_stack_if_any="ppc x86"
 fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
 fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
 fast_unaligned_if_any="armv6 ppc x86"
+local_aligned_8_if="aligned_stack"
+local_aligned_16_if="aligned_stack"
 
 need_memalign="altivec neon sse"
 inline_asm_deps="!tms470"
 
@@ -2629,10 +2631,8 @@  elif enabled mips; then
     enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
 
 elif enabled ppc; then
 
-    enable local_aligned_8 local_aligned_16
-
     check_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
     check_asm ibm_asm   '"add 0, 0, 0"'
     check_asm ppc4xx    '"maclhw r10, r11, r12"'
     check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
@@ -2667,10 +2667,8 @@  elif enabled sparc; then
         add_cflags -mcpu=ultrasparc -mtune=ultrasparc
 
 elif enabled x86; then
 
-    enable local_aligned_8 local_aligned_16
-
     # check whether EBP is available on x86
     # As 'i' is stored on the stack, this program will crash
     # if the base pointer is used to access it because the
     # base pointer is cleared in the inline assembly code.