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 c/108270] New: un-optimal vsetvl for multi-loop if avl is 0 ~ 31 immediate
Date: Tue, 03 Jan 2023 01:51:48 +0000	[thread overview]
Message-ID: <bug-108270-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 108270
           Summary: un-optimal vsetvl for multi-loop if avl is 0 ~ 31
                    immediate
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juzhe.zhong at rivai dot ai
  Target Milestone: ---

Consider this following case:

#include "riscv_vector.h"
void f1 (void * restrict in, void * restrict out, int l, int n, int m)
{
  for (int i = 0; i < l; i++){
    for (int j = 0; j < m; j++){
      for (int k = 0; k < n; k++)
        {
          vint8mf8_t v = __riscv_vle8_v_i8mf8 (in + i + j, 17);
          __riscv_vse8_v_i8mf8 (out + i + j, v, 17);
        }
    }
  }
}

GCC ASM:
f1:
0:      mv      a7,a2
1:      mv      a6,a0
2:      mv      t1,a1
3:      mv      a2,a3
4:      vsetivli        zero,17,e8,mf8,ta,ma
5:      ble     a7,zero,.L1
6:      ble     a4,zero,.L1
7:      ble     a3,zero,.L1
8:      add     a1,a0,a4
9:      li      a0,0
10:.L4:
11:     add     a3,a6,a0
12:     add     a4,t1,a0
13:.L7:
14:     li      a5,0
15:.L5:
16:     vle8.v  v24,0(a3)
17:     addiw   a5,a5,1
18:     vse8.v  v24,0(a4)
19:     bne     a2,a5,.L5
20:     addi    a3,a3,1
21:     addi    a4,a4,1
22:     bne     a3,a1,.L7
23:     addi    a0,a0,1
24:     addi    a1,a1,1
25:     bne     a0,a7,.L4
26:.L1:
27:     ret

The vsetivli instruction is hoisted too early. The best location of vsetivli
should be any point from 8 to 9.

             reply	other threads:[~2023-01-03  1:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03  1:51 juzhe.zhong at rivai dot ai [this message]
2023-01-03  1:52 ` [Bug c/108270] " juzhe.zhong at rivai dot ai
2023-04-21  9:49 ` [Bug target/108270] " cvs-commit at gcc dot gnu.org
2023-05-03 15:01 ` juzhe.zhong at rivai dot ai

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-108270-4@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).