public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108270] New: un-optimal vsetvl for multi-loop if avl is 0 ~ 31 immediate
@ 2023-01-03  1:51 juzhe.zhong at rivai dot ai
  2023-01-03  1:52 ` [Bug c/108270] " juzhe.zhong at rivai dot ai
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-01-03  1:51 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-03 15:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-03  1:51 [Bug c/108270] New: un-optimal vsetvl for multi-loop if avl is 0 ~ 31 immediate juzhe.zhong at rivai dot ai
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

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).