public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/94301] Missed vector-vector CTOR / permute simplification
Date: Tue, 01 Sep 2020 09:32:50 +0000	[thread overview]
Message-ID: <bug-94301-4-KUe3FMH4f8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94301-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Testcase

typedef double v1df __attribute__((vector_size(8)));
typedef double v2df __attribute__((vector_size(16)));
typedef long v2di __attribute__((vector_size(16)));

v2df __GIMPLE(ssa) foo (v1df x, v1df z)
{
  v2df y;

  __BB(2):
   y_2 = _Literal (v2df) { x_1(D), _Literal (v1df) { 0.0 } };
  y_3 = _Literal (v2df) { z_4(D), _Literal (v1df) { 0.0 } };
  y_5 = __VEC_PERM (y_2, y_3, _Literal (v2di) { 0l, 2l });
  y_6 = __VEC_PERM (y_5, y_5, _Literal (v2di) { 0l, 0l });
  return y_6;
}


> ./cc1 -quiet t.c -fgimple -O
during RTL pass: expand
t.c: In function 'foo':
t.c:5:20: internal compiler error: in require, at machmode.h:293
    5 | v2df __GIMPLE(ssa) foo (v1df x, v1df z)
      |                    ^~~
0xb84809 opt_mode<scalar_int_mode>::require() const
        /home/rguenther/src/gcc2/gcc/machmode.h:293
0xd5da8c store_integral_bit_field
        /home/rguenther/src/gcc2/gcc/expmed.c:1006
0xd5d2fe store_bit_field_1
        /home/rguenther/src/gcc2/gcc/expmed.c:873


works with -O0.  With -O we expand from

  y_2 = {x_1(D), { 0.0 }};
  y_4 = BIT_INSERT_EXPR <y_2, z_3(D), 64>;
  y_5 = VEC_PERM_EXPR <y_4, y_4, { 0, 0 }>;
  return y_5;

and the issue is that 'value' is

(mem/c:BLK (plus:DI (reg/f:DI 76 virtual-incoming-args)
        (const_int 8 [0x8])) [1 z+0 S8 A64])

because V1DF isn't a supported vector mode on x86_64 and vector lowering
doesn't do anything to it either.  Eventually V1m types should fall back to
the component mode transparently.  ABI-wise we seem to pass V1DF on the
stack ...

So the "simple" patch

diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index bde6fa22b58..90fc34e5a2c 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -512,6 +512,10 @@ mode_for_vector (scalar_mode innermode, poly_uint64
nunits)
        return mode;
     }

+  /* For single-element vectors, map it to the component mode.  */
+  if (known_eq (nunits, 1))
+    return innermode;
+
   return opt_machine_mode ();
 }


not only fixes the ICE and generates optimal code but also changes the ABI...

  parent reply	other threads:[~2020-09-01  9:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 14:43 [Bug tree-optimization/94301] New: " rguenth at gcc dot gnu.org
2020-03-24 15:13 ` [Bug tree-optimization/94301] " rguenth at gcc dot gnu.org
2020-09-01  9:32 ` rguenth at gcc dot gnu.org [this message]
2020-09-02  9:04 ` rguenth at gcc dot gnu.org
2021-12-12 13:26 ` 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-94301-4-KUe3FMH4f8@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).