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

--- Comment #12 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Ok, so SLP now works too, and

#include <arm_neon.h>

void foo (uint8_t *a, uint8_t *b, uint8_t *c, int n)
{
  for (int i = 0; i < n; i+=16, a+=16, b+=16, c+=16)
    {
        uint8x8_t av1 = vld1_u8 (a);
        uint8x8_t av2 = vld1_u8 (a+8);
        uint8x8_t bv1 = vld1_u8 (b);
        uint8x8_t bv2 = vld1_u8 (b+8);
        vst1_u8 (c, vadd_u8 (av1, bv1));
        vst1_u8 (c+8, vadd_u8 (av2, bv2));
    }
}

and

#include <arm_neon.h>

void foo2 (uint8_t *a, uint8_t *b, uint8_t *c, int n)
{
  uint8x8_t av1 = vld1_u8 (a);
  uint8x8_t av2 = vld1_u8 (a+8);
  uint8x8_t bv1 = vld1_u8 (b);
  uint8x8_t bv2 = vld1_u8 (b+8);
  vst1_u8 (c, vadd_u8 (av1, bv1));
  vst1_u8 (c+8, vadd_u8 (av2, bv2));
}

work, obviously the last one can't yet use SVE codegen until Chris's VLA BB
patch lands.

I still need to work on it recognizing

#include <arm_neon.h>

void foo (uint8_t *a, uint8_t *b, uint8_t *c, int n)
{
  for (int i = 0; i < n; i+=16, a+=16, b+=16, c+=16)
    {
        uint8x8_t av1 = vld1_u8 (a);
        uint8x8_t bv1 = vld1_u8 (b);
        vst1_u8 (c, vadd_u8 (av1, bv1));
        c[i+8] = a[i+8] + b[i+8];
        c[i+9] = a[i+9] + b[i+9];
        c[i+10] = a[i+10] + b[i+10];
        c[i+11] = a[i+11] + b[i+11];
        c[i+12] = a[i+12] + b[i+12];
        c[i+13] = a[i+13] + b[i+13];
        c[i+14] = a[i+14] + b[i+14];
        c[i+15] = a[i+15] + b[i+15];
    }
}

to be seen as the being the same operation.  In particular the MEM nodes make
it create two SLP nodes instead of one (bleh).

#include <arm_neon.h>

void foo (uint8_t *a, uint8_t *b, uint8_t *c, int n)
{
  for (int i = 0; i < n; i+=9, a+=9, b+=9, c+=9)
    {
        uint8x8_t av1 = vld1_u8 (a);
        uint8x8_t bv1 = vld1_u8 (b);
        vst1_u8 (c, vadd_u8 (av1, bv1));
        c[i+8] = a[i+8] + b[i+8];
    }
}

I'm not sure about and I reject.  For non partial vectors this would need 8x
unrolling to fill the lanes,  But the scalar code would be a gather.  So it's
really unlikely to be beneficial.

for a partial loop however we can in principal support it, as the group size
does not matter in that case and a non-power of 2 lanes doesn't need to become
a power of two.

I'm not exactly sure yet what's the cleanest way to support this is atm.  So
need a bit more thought.

Now these are all instructions that have been lowered.  For things that aren't
and are a builtin still either:

1. providing a variant of get_conditional_internal_fn and other helpers as e.g.
get_conditional_fn that allows a target to provide target specific built-in
conversions.  This requires other helper methods to behave the same, like
internal_fn_mask_index.  So there would be a reasonable number of hooks..

2. Abstract that all away using .MASK_CALL, which removed the churn in the
vectorizer but lower this in gimple-isel.  The problem is how to check the
availability of the masked call.  vectorizable_simd_clone_call relies on target
simd clone information today.  So I think we'd need a new target hook here. 
But  that would mean we only need only 1 new hook, as gimple-isel already has
what it needs to do the target specific selection.

3. Something new to handle the query and transformation.  But I don't think
introducing a third method makes sense.


For now I can progress without resolving these but need to at some point.

Reply via email to