public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "crazylht at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/97249] Missing vec_select and subreg optimization
Date: Tue, 13 Oct 2020 06:08:04 +0000	[thread overview]
Message-ID: <bug-97249-4-q74xkKUBFf@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-97249-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from Hongtao.liu <crazylht at gmail dot com> ---
I'm testing
---
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 869f0d11b2e..9c397157f28 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -4170,6 +4170,33 @@ simplify_binary_operation_1 (enum rtx_code code,
machine_mode mode,
                    return subop1;
                }
            }
+
+         /* For cases like
+            (vec_select:V2SI (subreg:V4SI (inner:V2SI) 0)
+                             (parallel [(const_int 0) (const_int 1)])).
+            return inner directly.  */
+         if (GET_CODE (trueop0) == SUBREG
+             && paradoxical_subreg_p (trueop0)
+             && mode == GET_MODE (XEXP (trueop0, 0))
+             && (GET_MODE_NUNITS (GET_MODE (trueop0))).is_constant (&l0)
+             && (GET_MODE_NUNITS (mode)).is_constant (&l1)
+             && l0 % l1 == 0)
+           {
+             gcc_assert (known_eq (XVECLEN (trueop1, 0), l1));
+             unsigned HOST_WIDE_INT expect = (HOST_WIDE_INT_1U << l1) - 1;
+             unsigned HOST_WIDE_INT sel = 0;
+             int i = 0;
+             for (;i != l1; i++)
+               {
+                 rtx j = XVECEXP (trueop1, 0, i);
+                 if (!CONST_INT_P (j))
+                   break;
+                 sel |= HOST_WIDE_INT_1U << UINTVAL (j);
+               }
+             /* ??? Need to simplify XEXP (trueop0, 0) here.  */
+             if (sel == expect)
+               return XEXP (trueop0, 0);
+           }
        }

       if (XVECLEN (trueop1, 0) == 1
---

  parent reply	other threads:[~2020-10-13  6:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-30  6:30 [Bug rtl-optimization/97249] New: " crazylht at gmail dot com
2020-09-30  6:38 ` [Bug rtl-optimization/97249] " crazylht at gmail dot com
2020-09-30  6:39 ` crazylht at gmail dot com
2020-09-30  6:48 ` rguenth at gcc dot gnu.org
2020-10-12  2:23 ` crazylht at gmail dot com
2020-10-12 14:53 ` segher at gcc dot gnu.org
2020-10-13  1:59 ` crazylht at gmail dot com
2020-10-13  6:08 ` crazylht at gmail dot com [this message]
2020-10-22  3:38 ` cvs-commit at gcc dot gnu.org
2020-10-22  3:38 ` crazylht at gmail dot com
2021-08-21 18: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-97249-4-q74xkKUBFf@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).