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 tree-optimization/99882] [11 Regression] ICE in bswap_view_convert, at gimple-ssa-store-merging.c:988 since r11-7946-g5b9a65ecbeb22ef6
Date: Fri, 02 Apr 2021 14:55:46 +0000	[thread overview]
Message-ID: <bug-99882-4-DTObNvGcls@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99882-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Untested fix:
--- gcc/gimple-ssa-store-merging.c.jj   2021-04-01 10:50:56.238629197 +0200
+++ gcc/gimple-ssa-store-merging.c      2021-04-02 16:52:38.763803716 +0200
@@ -985,10 +985,19 @@ public:
 static tree
 bswap_view_convert (gimple_stmt_iterator *gsi, tree type, tree val)
 {
-  gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (val)));
+  gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (val))
+             || POINTER_TYPE_P (TREE_TYPE (val)));
   if (TYPE_SIZE (type) != TYPE_SIZE (TREE_TYPE (val)))
     {
       HOST_WIDE_INT prec = TREE_INT_CST_LOW (TYPE_SIZE (type));
+      if (POINTER_TYPE_P (TREE_TYPE (val)))
+       {
+         gimple *g
+           = gimple_build_assign (make_ssa_name (pointer_sized_int_node),
+                                  NOP_EXPR, val);
+         gsi_insert_before (gsi, g, GSI_SAME_STMT);
+         val = gimple_assign_lhs (g);
+       }
       tree itype = build_nonstandard_integer_type (prec, 1);
       gimple *g = gimple_build_assign (make_ssa_name (itype), NOP_EXPR, val);
       gsi_insert_before (gsi, g, GSI_SAME_STMT);

Slightly cleaned up testcase:
void
foo (char *p, void *q)
{
  __INTPTR_TYPE__ i = (__INTPTR_TYPE__) q;
  p[2] = i;
  i >>= 8;
  p[3] = i;
  i >>= 8;
  p[4] = i;
  i >>= 8;
  p[5] = i;
  i >>= 8;
  p[6] = i;
  i >>= 8;
  p[7] = i;
  i >>= 8;
  p[8] = i;
  i >>= 8;
  p[9] = i;
}

void
bar (char *p, void *q)
{
  __INTPTR_TYPE__ i = (__INTPTR_TYPE__) q;
  p[2] = i;
  i >>= 8;
  p[3] = i;
  i >>= 8;
  p[4] = i;
  i >>= 8;
  p[5] = i;
}

  parent reply	other threads:[~2021-04-02 14:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 12:06 [Bug tree-optimization/99882] New: " marxin at gcc dot gnu.org
2021-04-02 12:06 ` [Bug tree-optimization/99882] " marxin at gcc dot gnu.org
2021-04-02 14:55 ` jakub at gcc dot gnu.org [this message]
2021-04-03  8:08 ` cvs-commit at gcc dot gnu.org
2021-04-03  8:17 ` jakub 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-99882-4-DTObNvGcls@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).