public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111794] New: RISC-V: Missed SLP optimization due to mask mode precision
@ 2023-10-13  7:41 juzhe.zhong at rivai dot ai
  2023-10-13  7:47 ` [Bug c/111794] " juzhe.zhong at rivai dot ai
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-10-13  7:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111794
           Summary: RISC-V: Missed SLP optimization due to mask mode
                    precision
           Product: gcc
           Version: 14.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: ---

void
f (int *restrict x, short *restrict y)
{
  x[0] = x[0] == 1 & y[0] == 2;
  x[1] = x[1] == 1 & y[1] == 2;
  x[2] = x[2] == 1 & y[2] == 2;
  x[3] = x[3] == 1 & y[3] == 2;
  x[4] = x[4] == 1 & y[4] == 2;
  x[5] = x[5] == 1 & y[5] == 2;
  x[6] = x[6] == 1 & y[6] == 2;
  x[7] = x[7] == 1 & y[7] == 2;
}

Realize that we failed to vectorize this case:

https://godbolt.org/z/rWz9fjM4r

The root cause is the mask bit precision of "small mask mode" (Potentially has 
bitsize smaller than 1 bytes).

If we remove this following adjust precision:

ADJUST_PRECISION (V1BI, 1);
ADJUST_PRECISION (V2BI, 2);
ADJUST_PRECISION (V4BI, 4);

ADJUST_PRECISION (RVVMF16BI, riscv_v_adjust_precision (RVVMF16BImode, 4));
ADJUST_PRECISION (RVVMF32BI, riscv_v_adjust_precision (RVVMF32BImode, 2));
ADJUST_PRECISION (RVVMF64BI, riscv_v_adjust_precision (RVVMF64BImode, 1));

It can vectorize such case but will cause bugs in other situations.

Is it possible to fix that in GCC?

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

end of thread, other threads:[~2023-11-01  2:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-13  7:41 [Bug c/111794] New: RISC-V: Missed SLP optimization due to mask mode precision juzhe.zhong at rivai dot ai
2023-10-13  7:47 ` [Bug c/111794] " juzhe.zhong at rivai dot ai
2023-10-13  7:51 ` juzhe.zhong at rivai dot ai
2023-10-13  8:13 ` rguenth at gcc dot gnu.org
2023-10-13  8:17 ` rdapp at gcc dot gnu.org
2023-10-16  7:56 ` rdapp at gcc dot gnu.org
2023-10-16  8:50 ` rguenther at suse dot de
2023-10-16  9:05 ` rdapp at gcc dot gnu.org
2023-10-16  9:29 ` rguenther at suse dot de
2023-10-16  9:58 ` rdapp at gcc dot gnu.org
2023-10-16 14:23 ` rdapp at gcc dot gnu.org
2023-10-23 16:44 ` [Bug tree-optimization/111794] " cvs-commit at gcc dot gnu.org
2023-11-01  2:31 ` 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).