public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/54201] XMM constant duplicated
Date: Mon, 31 Aug 2020 17:20:31 +0000	[thread overview]
Message-ID: <bug-54201-4-Qk5m5OhPf7@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-54201-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54201

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The .rodata duplication should now be gone with the above commit.

I've tried

--- gcc/varasm.c.jj     2020-08-31 10:26:56.978179325 +0200
+++ gcc/varasm.c        2020-08-31 19:15:34.563274307 +0200
@@ -3818,6 +3818,38 @@ force_const_mem (machine_mode in_mode, r
   if (!is_a <fixed_size_mode> (in_mode, &mode))
     return NULL_RTX;

+  /* Try to canonicalize CONST_VECTORs.  See PR54201.  */
+  if (GET_CODE (x) == CONST_VECTOR)
+    {
+      machine_mode cmode = MIN_MODE_VECTOR_INT;
+      machine_mode altmode = VOIDmode;
+
+      /* Choose a MODE_VECTOR_INT mode with the same size as in_mode
+        and as large as possible element, as long as the element is
+        at most HWI sized (so that CONST_INTs can be used rather
+        than CONST_DOUBLEs or CONST_WIDE_INTs.  */
+      FOR_EACH_MODE_FROM (cmode, cmode)
+       if (known_eq (GET_MODE_SIZE (cmode), GET_MODE_SIZE (in_mode))
+           && known_le (GET_MODE_SIZE (GET_MODE_INNER (cmode)),
+                        HOST_BITS_PER_WIDE_INT)
+           && (altmode == VOIDmode
+               || (GET_MODE_SIZE (GET_MODE_INNER (cmode))
+                   > GET_MODE_SIZE (GET_MODE_INNER (altmode)))))
+         altmode = cmode;
+      if (altmode != VOIDmode && altmode != in_mode)
+       {
+         rtx altx = simplify_subreg (altmode, x, in_mode, 0);
+         if (altx && GET_CODE (altx) == CONST_VECTOR)
+           {
+             rtx altret = force_const_mem (altmode, altx);
+             if (altret)
+               {
+                 PUT_MODE (altret, in_mode);
+                 return altret;
+               }
+           }
+       }
+    }
   /* If we're not allowed to drop X into the constant pool, don't.  */
   if (targetm.cannot_force_const_mem (mode, x))
     return NULL_RTX;

as a variant of Richi's patch, but e.g. on
typedef int V __attribute__((vector_size (16)));
typedef long long int W __attribute__((vector_size (16)));
typedef float X __attribute__((vector_size (16)));

void
foo (V *v, W *w, X *x)
{
  *v += (V) (X) { 2.0f, 2.0f, 2.0f, 2.0f };
  *w += (W) (X) { 2.0f, 2.0f, 2.0f, 2.0f };
  *x += (X) { 2.0f, 2.0f, 2.0f, 2.0f };
}
nothing will really try to share the loads, so the question is if it would gain
us anything.

  parent reply	other threads:[~2020-08-31 17:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-08 11:31 [Bug target/54201] New: " cesarb at cesarb dot net
2012-08-08 11:32 ` [Bug target/54201] " cesarb at cesarb dot net
2012-08-08 11:53 ` [Bug middle-end/54201] " rguenth at gcc dot gnu.org
2012-08-08 23:29 ` cesarb at cesarb dot net
2012-08-09  9:50 ` rguenth at gcc dot gnu.org
2012-08-09 10:22 ` rguenth at gcc dot gnu.org
2012-08-13 12:43 ` rguenth at gcc dot gnu.org
2012-08-14 13:21 ` rguenth at gcc dot gnu.org
2012-08-14 14:38 ` rguenth at gcc dot gnu.org
2012-08-15  9:03 ` rguenth at gcc dot gnu.org
2020-08-31  8:30 ` cvs-commit at gcc dot gnu.org
2020-08-31 17:20 ` jakub at gcc dot gnu.org [this message]
2021-08-21 23:24 ` pinskia at gcc dot gnu.org
2021-08-21 23:28 ` pinskia at gcc dot gnu.org

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=bug-54201-4-Qk5m5OhPf7@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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: 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).