public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "juzhe.zhong at rivai dot ai" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/99395] s116 benchmark of TSVC is vectorized by clang and not by gcc
Date: Wed, 31 Jan 2024 01:32:45 +0000	[thread overview]
Message-ID: <bug-99395-4-yMSTefOI2i@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99395-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #10 from JuzheZhong <juzhe.zhong at rivai dot ai> ---

I think the root cause is we think i_16 and _1 are alias due to scalar
evolution:

(get_scalar_evolution 
  (scalar = i_16)
  (scalar_evolution = {0, +, 2}<nw>_1))

(get_scalar_evolution 
  (scalar = _1)
  (scalar_evolution = {1, +, 2}<nw>_1))

Even though I didn't understand what it is.

diff --git a/gcc/tree-scalar-evolution.cc b/gcc/tree-scalar-evolution.cc
index 25e3130e2f1..2df6de67043 100644
--- a/gcc/tree-scalar-evolution.cc
+++ b/gcc/tree-scalar-evolution.cc
@@ -553,7 +553,7 @@ get_scalar_evolution (basic_block instantiated_below, tree
scalar)
         if (SSA_NAME_IS_DEFAULT_DEF (scalar))
          res = scalar;
        else
-         res = *find_var_scev_info (instantiated_below, scalar);
+         res = scalar;
        break;

       case REAL_CST:

Ah... I tried an ugly hack which is definitely wrong (just for experiment) in
scalar evolution.

Then, we can vectorize it:

foo:
        lui     a1,%hi(a)
        addi    a1,a1,%lo(a)
        li      a2,511
        li      a3,0
        vsetivli        zero,2,e64,m1,ta,ma
.L2:
        addiw   a5,a3,1
        slli    a5,a5,3
        add     a5,a1,a5
        fld     fa5,0(a5)
        slli    a4,a3,3
        add     a4,a1,a4
        vlse64.v        v2,0(a4),zero
        vle64.v v1,0(a5)
        vfslide1down.vf v2,v2,fa5
        addiw   a2,a2,-1
        vfmul.vv        v1,v1,v2
        vse64.v v1,0(a4)
        addiw   a3,a3,2
        bne     a2,zero,.L2
        ret

I think we can add some simple memory access index recognition, but I don't
known where to add this recognition.

Would you mind giving me some more hints ?

Thanks.

  parent reply	other threads:[~2024-01-31  1:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 23:01 [Bug middle-end/99395] New: " hubicka at gcc dot gnu.org
2021-03-04 23:24 ` [Bug middle-end/99395] " hubicka at gcc dot gnu.org
2021-03-05  8:27 ` [Bug tree-optimization/99395] " rguenth at gcc dot gnu.org
2021-03-05 15:42 ` hubicka at gcc dot gnu.org
2022-10-18 10:28 ` rguenth at gcc dot gnu.org
2022-10-18 10:37 ` rguenth at gcc dot gnu.org
2023-10-07  9:10 ` juzhe.zhong at rivai dot ai
2023-10-09  6:30 ` rguenth at gcc dot gnu.org
2024-01-30 11:37 ` juzhe.zhong at rivai dot ai
2024-01-30 12:26 ` rguenth at gcc dot gnu.org
2024-01-31  1:32 ` juzhe.zhong at rivai dot ai [this message]
2024-01-31  3:50 ` juzhe.zhong at rivai dot ai
2024-01-31  7:00 ` juzhe.zhong at rivai dot ai
2024-01-31  7:59 ` rguenth at gcc dot gnu.org
2024-01-31  8:09 ` juzhe.zhong at rivai dot ai
2024-01-31  8:18 ` rguenther at suse dot de
2024-01-31  8:27 ` juzhe.zhong at rivai dot ai
2024-01-31  9:08 ` rguenther at suse dot de
2024-01-31  9:19 ` juzhe.zhong at rivai dot ai
2024-01-31  9:56 ` rguenther at suse dot de
2024-04-07 21:33 ` 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-99395-4-yMSTefOI2i@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).