From 3396aba5384e904199530f8efea4c1eaaab51605 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 9 Jan 2014 21:12:36 +0100 Subject: [PATCH] re PR middle-end/47735 (Unnecessary adjustments to stack pointer) PR middle-end/47735 * cfgexpand.c (expand_one_var): For SSA_NAMEs, if the underlying var satisfies use_register_for_decl, just take into account type alignment, rather than decl alignment. * gcc.target/i386/pr47735.c: New test. From-SVN: r206493 --- gcc/ChangeLog | 5 +++++ gcc/cfgexpand.c | 7 +++++-- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.target/i386/pr47735.c | 16 ++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr47735.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7d000f2b9b5..c87697ff17a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2014-01-09 Jakub Jelinek + PR middle-end/47735 + * cfgexpand.c (expand_one_var): For SSA_NAMEs, if the underlying + var satisfies use_register_for_decl, just take into account type + alignment, rather than decl alignment. + PR tree-optimization/59622 * gimple-fold.c (gimple_fold_call): Fix a typo in message. For __builtin_unreachable replace the OBJ_TYPE_REF call with a call to diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 5f14d813fbd..c0cbeb3c022 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -1215,8 +1215,11 @@ expand_one_var (tree var, bool toplevel, bool really_expand) we conservatively assume it will be on stack even if VAR is eventually put into register after RA pass. For non-automatic variables, which won't be on stack, we collect alignment of - type and ignore user specified alignment. */ - if (TREE_STATIC (var) || DECL_EXTERNAL (var)) + type and ignore user specified alignment. Similarly for + SSA_NAMEs for which use_register_for_decl returns true. */ + if (TREE_STATIC (var) + || DECL_EXTERNAL (var) + || (TREE_CODE (origvar) == SSA_NAME && use_register_for_decl (var))) align = MINIMUM_ALIGNMENT (TREE_TYPE (var), TYPE_MODE (TREE_TYPE (var)), TYPE_ALIGN (TREE_TYPE (var))); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d6a7a01dac9..0957d841140 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2014-01-09 Jakub Jelinek + PR middle-end/47735 + * gcc.target/i386/pr47735.c: New test. + PR tree-optimization/59622 * g++.dg/opt/pr59622-2.C: New test. * g++.dg/opt/pr59622-3.C: New test. diff --git a/gcc/testsuite/gcc.target/i386/pr47735.c b/gcc/testsuite/gcc.target/i386/pr47735.c new file mode 100644 index 00000000000..0d44df4d5c9 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr47735.c @@ -0,0 +1,16 @@ +/* PR middle-end/47735 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fomit-frame-pointer" } */ + +unsigned +mulh (unsigned a, unsigned b) +{ + unsigned long long l __attribute__ ((aligned (32))) + = ((unsigned long long) a * (unsigned long long) b) >> 32; + return l; +} + +/* No need to dynamically realign the stack here. */ +/* { dg-final { scan-assembler-not "and\[^\n\r]*%\[re\]sp" } } */ +/* Nor use a frame pointer. */ +/* { dg-final { scan-assembler-not "%\[re\]bp" } } */