public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111232] New: RISC-V: Failed to combine vwmul + vadd into vwmacc
@ 2023-08-30  7:00 juzhe.zhong at rivai dot ai
  2023-09-01  3:24 ` [Bug target/111232] " lehua.ding at rivai dot ai
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-08-30  7:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111232
           Summary: RISC-V: Failed to combine vwmul + vadd into vwmacc
           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: ---

#include <stdlib.h>
#define N 64

#define DOT -21856

signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) =
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63};
signed char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) =
{64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1};

/* char->short->short dot product.
   The dot-product pattern should be detected.
   Should be vectorized on vect_sdot_qi targets (targets that support 
   dot-product of signed char).  
   This test currently fails to vectorize on targets that support
   dot-product of chars into and int accumulator.
   Can also be vectorized as widening-mult + summation,
   or with type-conversion support.
 */
__attribute__ ((noinline)) short
foo(int len) {
  int i;
  short result = 0;

  for (i=0; i<len; i++) {
    result += (X[i] * Y[i]);
  }
  return result;
}

ASM:

        vsetvli a5,a0,e8,mf2,ta,ma
        vle8.v  v4,0(a4)
        vle8.v  v3,0(a3)
        sub     a0,a0,a5
        vsetvli a2,zero,e8,mf2,ta,ma
        add     a4,a4,a5
        vwmul.vv        v2,v4,v3
        add     a3,a3,a5
        vsetvli zero,a5,e16,m1,tu,ma
        vadd.vv v1,v2,v1
        bne     a0,zero,.L8
        vsetvli a2,zero,e16,m1,ta,ma
        vmv.s.x v2,zero
        vredsum.vs      v1,v1,v2
        vmv.x.s a0,v1
        ret

It should be vwmacc instead of vwmul + vadd.

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

end of thread, other threads:[~2023-09-06 12:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-30  7:00 [Bug c/111232] New: RISC-V: Failed to combine vwmul + vadd into vwmacc juzhe.zhong at rivai dot ai
2023-09-01  3:24 ` [Bug target/111232] " lehua.ding at rivai dot ai
2023-09-06  9:56 ` cvs-commit at gcc dot gnu.org
2023-09-06 12:49 ` 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).