Trouble Shooting SLP not Working for the RISC-V

Hi there:

Recently I tried the upstream and release/15.x of the llvm project. I did some investigating with the sample code for the SLP support for the RISC-V.

Compared to X86, the SLP have taken no effect on the RISC-V. For example, as below. I would like to double confirm if there is something I missed before figuring it out with the potential fix.

Sample code for the SLP.

void single_loop_with_slp_vectorization(int *result,
                                        int a1, int a2,
                                        int b1, int b2) {
  int value = (a2 + b2) & (a1 + b1);

  result[0] = value;
  result[1] = value;
  result[2] = value;
  result[3] = value;

  result[4] = value;
  result[5] = value;
  result[6] = value;
  result[7] = value;

X86_64 assembly code

  44 01 c2                add    %r8d,%edx
  01 ce                   add    %ecx,%esi
  21 d6                   and    %edx,%esi
  66 0f 6e c6             movd   %esi,%xmm0
  66 0f 70 c0 00          pshufd $0x0,%xmm0,%xmm0
  f3 0f 7f 07             movdqu %xmm0,(%rdi)
  f3 0f 7f 47 10          movdqu %xmm0,0x10(%rdi)
  f3 0f 7f 47 20          movdqu %xmm0,0x20(%rdi)
  f3 0f 7f 47 30          movdqu %xmm0,0x30(%rdi)
  c3                      ret

RISC-V assembly code

  9e39                    addw    a2,a2,a4
  9db5                    addw    a1,a1,a3
  8df1                    and     a1,a1,a2
  c10c                    sw      a1,0(a0)
  c14c                    sw      a1,4(a0)
  c50c                    sw      a1,8(a0)
  c54c                    sw      a1,12(a0)
  c90c                    sw      a1,16(a0)
  c94c                    sw      a1,20(a0)
  cd0c                    sw      a1,24(a0)
  cd4c                    sw      a1,28(a0)
  8082                    ret

Thank you in advance, and nice day.

Since the cost model is not tuned well for RISC-V, SLP vectorizer is currently disabled for RISC-V.

Thank you! May I know is any plan for this? I am not sure if there is something I can do to make it happen.

The plan is to tune the cost model and then enable SLP vectotizer, I assume. Try to contact Philip Reames.

Sure, thank you! Let me contact Philip Reames for more details.