public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5133] Apply pattern initialization only when have_insn_for return true.
@ 2021-11-10 17:59 Qing Zhao
0 siblings, 0 replies; only message in thread
From: Qing Zhao @ 2021-11-10 17:59 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1c04af34c9c66d8ed9f6c12c97dd064238ddfa20
commit r12-5133-g1c04af34c9c66d8ed9f6c12c97dd064238ddfa20
Author: Qing Zhao <qing.zhao@oracle.com>
Date: Wed Nov 10 17:59:31 2021 +0000
Apply pattern initialization only when have_insn_for return true.
For -ftrivial-auto-var-init=pattern, initialize the variable with patterns only
when have_insn_for (SET, mode) return true. Otherwise initialize it with zeros.
with this change, _Complex long double on X86 is initialized to zero for
pattern initialization.
gcc/ChangeLog:
2021-11-10 qing zhao <qing.zhao@oracle.com>
* internal-fn.c (expand_DEFERRED_INIT): Apply pattern initialization
only when have_insn_for return true for the mode. Fix a memory leak.
gcc/testsuite/ChangeLog:
2021-11-10 qing zhao <qing.zhao@oracle.com>
* gcc.target/i386/auto-init-6.c: _Complex long double is initialized
to zero now with -ftrivial-auto-var-init=pattern.
Diff:
---
gcc/internal-fn.c | 14 ++++++++------
gcc/testsuite/gcc.target/i386/auto-init-6.c | 6 ++++--
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index 0cba95411a6..e8fd16b9c21 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -3059,10 +3059,10 @@ expand_DEFERRED_INIT (internal_fn, gcall *stmt)
mark_addressable (lhs);
tree var_addr = build_fold_addr_expr (lhs);
- tree value = (init_type == AUTO_INIT_PATTERN) ?
- build_int_cst (integer_type_node,
- INIT_PATTERN_VALUE) :
- integer_zero_node;
+ tree value = (init_type == AUTO_INIT_PATTERN)
+ ? build_int_cst (integer_type_node,
+ INIT_PATTERN_VALUE)
+ : integer_zero_node;
tree m_call = build_call_expr (builtin_decl_implicit (BUILT_IN_MEMSET),
3, var_addr, value, var_size);
/* Expand this memset call. */
@@ -3073,15 +3073,17 @@ expand_DEFERRED_INIT (internal_fn, gcall *stmt)
/* If this variable is in a register use expand_assignment.
For boolean scalars force zero-init. */
tree init;
+ scalar_int_mode var_mode;
if (TREE_CODE (TREE_TYPE (lhs)) != BOOLEAN_TYPE
&& tree_fits_uhwi_p (var_size)
&& (init_type == AUTO_INIT_PATTERN
|| !is_gimple_reg_type (var_type))
&& int_mode_for_size (tree_to_uhwi (var_size) * BITS_PER_UNIT,
- 0).exists ())
+ 0).exists (&var_mode)
+ && have_insn_for (SET, var_mode))
{
unsigned HOST_WIDE_INT total_bytes = tree_to_uhwi (var_size);
- unsigned char *buf = (unsigned char *) xmalloc (total_bytes);
+ unsigned char *buf = XALLOCAVEC (unsigned char, total_bytes);
memset (buf, (init_type == AUTO_INIT_PATTERN
? INIT_PATTERN_VALUE : 0), total_bytes);
tree itype = build_nonstandard_integer_type
diff --git a/gcc/testsuite/gcc.target/i386/auto-init-6.c b/gcc/testsuite/gcc.target/i386/auto-init-6.c
index 339f8bc2966..e53385f0eb7 100644
--- a/gcc/testsuite/gcc.target/i386/auto-init-6.c
+++ b/gcc/testsuite/gcc.target/i386/auto-init-6.c
@@ -1,4 +1,6 @@
/* Verify pattern initialization for complex type automatic variables. */
+/* Note, _Complex long double is initialized to zeroes due to the current
+ implemenation limitation. */
/* { dg-do compile } */
/* { dg-options "-ftrivial-auto-var-init=pattern -march=x86-64 -mtune=generic -msse" } */
@@ -15,6 +17,6 @@ _Complex long double foo()
return result;
}
-/* { dg-final { scan-assembler-times "long\t-16843010" 10 { target { ! ia32 } } } } */
-/* { dg-final { scan-assembler-times "long\t-16843010" 6 { target { ia32 } } } } */
+/* { dg-final { scan-assembler-times "long\t0" 8 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "long\t-16843010" 6 } } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-11-10 17:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10 17:59 [gcc r12-5133] Apply pattern initialization only when have_insn_for return true Qing Zhao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).