public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Qing Zhao <qinzhao@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5133] Apply pattern initialization only when have_insn_for return true. Date: Wed, 10 Nov 2021 17:59:52 +0000 (GMT) [thread overview] Message-ID: <20211110175952.5DFEB3857C52@sourceware.org> (raw) 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 } } */
reply other threads:[~2021-11-10 17:59 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211110175952.5DFEB3857C52@sourceware.org \ --to=qinzhao@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).