From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] bitint, v2: Avoid rewriting large/huge _BitInt vars into SSA after bitint lowering [PR114278]
Date: Mon, 11 Mar 2024 08:49:29 +0100 [thread overview]
Message-ID: <Ze63iegnAMjJjInd@tucnak> (raw)
In-Reply-To: <75DCD6B5-A571-46F4-B735-F5C9DE2F0949@suse.de>
On Sat, Mar 09, 2024 at 12:25:42PM +0100, Richard Biener wrote:
> Ideally we’d clear TREE_ADDRESSABLE but set DECL_NOT_GIMPLE_REG,
> I think the analysis where we check the base would be a more
> appropriate place to enforce that.
So like this?
Bootstrapped/regtested on x86_64-linux and i686-linux.
2024-03-11 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/114278
* tree-ssa.cc (maybe_optimize_var): If large/huge _BitInt vars are no
longer addressable, set DECL_NOT_GIMPLE_REG_P on them.
* gcc.dg/bitint-99.c: New test.
--- gcc/tree-ssa.cc.jj 2024-01-03 11:51:39.902615009 +0100
+++ gcc/tree-ssa.cc 2024-03-09 23:34:12.469223987 +0100
@@ -1785,6 +1785,20 @@ maybe_optimize_var (tree var, bitmap add
fprintf (dump_file, "\n");
}
}
+ else if (TREE_CODE (TREE_TYPE (var)) == BITINT_TYPE
+ && (cfun->curr_properties & PROP_gimple_lbitint) != 0
+ && TYPE_PRECISION (TREE_TYPE (var)) > MAX_FIXED_MODE_SIZE)
+ {
+ /* Don't rewrite large/huge _BitInt vars after _BitInt lowering
+ into SSA form. */
+ DECL_NOT_GIMPLE_REG_P (var) = 1;
+ if (dump_file)
+ {
+ fprintf (dump_file, "_BitInt var after its lowering: ");
+ print_generic_expr (dump_file, var);
+ fprintf (dump_file, "\n");
+ }
+ }
else if (DECL_NOT_GIMPLE_REG_P (var))
{
maybe_reg = true;
--- gcc/testsuite/gcc.dg/bitint-99.c.jj 2024-03-08 14:26:17.658069942 +0100
+++ gcc/testsuite/gcc.dg/bitint-99.c 2024-03-08 14:25:36.292645965 +0100
@@ -0,0 +1,26 @@
+/* PR tree-optimization/114278 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O2 -fno-tree-dce -fno-tree-dse -fno-tree-ccp" } */
+/* { dg-additional-options "-mavx2" { target i?86-*-* x86_64-*-* } } */
+
+void
+foo (void *p)
+{
+ _BitInt(64) b = *(_BitInt(64) *) __builtin_memmove (&b, p, sizeof (_BitInt(64)));
+}
+
+#if __BITINT_MAXWIDTH__ >= 128
+void
+bar (void *p)
+{
+ _BitInt(128) b = *(_BitInt(128) *) __builtin_memmove (&b, p, sizeof (_BitInt(128)));
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 256
+void
+baz (void *p)
+{
+ _BitInt(256) b = *(_BitInt(256) *) __builtin_memmove (&b, p, sizeof (_BitInt(256)));
+}
+#endif
Jakub
next prev parent reply other threads:[~2024-03-11 7:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-09 8:22 [PATCH] bitint: " Jakub Jelinek
2024-03-09 11:25 ` Richard Biener
2024-03-11 7:49 ` Jakub Jelinek [this message]
2024-03-11 10:31 ` [PATCH] bitint, v2: " Richard Biener
2024-03-11 10:40 ` Jakub Jelinek
2024-03-11 10:47 ` Richard Biener
2024-03-11 9:51 ` [PATCH] bitint: " Richard Biener
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=Ze63iegnAMjJjInd@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
/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: link
Be 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).