<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [SIMD] shuffle even/odd, extend, add should generate extadd_pairwise"
   href="https://bugs.llvm.org/show_bug.cgi?id=50808">50808</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[SIMD] shuffle even/odd, extend, add should generate extadd_pairwise
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: WebAssembly
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>clang@evan.coeusgroup.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>With -msimd128, shuffling to extract even and odd elements, then extending
those and adding the result should result in one of the extadd_pairwise
instructions (assuming 8 or 16 bit inputs).  It doesn't.

Right now they result in some rather atrocious code, but I filed that as
#50807.  This issue is about generating an extadd_pairwise instruction.

Example (Compiler Explorer: <a href="https://godbolt.org/z/94n6sooTs">https://godbolt.org/z/94n6sooTs</a>):



#include <stdint.h>

#pragma clang diagnostic ignored "-Wmissing-prototypes"

typedef   int8_t i8x16 __attribute__((__vector_size__(16)));
typedef  int16_t i16x8 __attribute__((__vector_size__(16)));
typedef  int32_t i32x4 __attribute__((__vector_size__(16)));
typedef  uint8_t u8x16 __attribute__((__vector_size__(16)));
typedef uint16_t u16x8 __attribute__((__vector_size__(16)));
typedef uint32_t u32x4 __attribute__((__vector_size__(16)));

i16x8
i8x16_extadd_pairwise(i8x16 a) {
    return (i16x8) {
      __builtin_convertvector(__builtin_shufflevector(a, a, 0, 2, 4, 6, 8, 10,
12, 14), i16x8) +
      __builtin_convertvector(__builtin_shufflevector(a, a, 1, 3, 5, 7, 9, 11,
13, 15), i16x8)  
    };
}

i32x4
i16x8_extadd_pairwise(i16x8 a) {
    return (i32x4) {
      __builtin_convertvector(__builtin_shufflevector(a, a, 0, 2, 4, 6), i32x4)
+
      __builtin_convertvector(__builtin_shufflevector(a, a, 1, 3, 5, 7), i32x4) 
    };
}

u16x8
u8x16_extadd_pairwise(i8x16 a) {
    return (u16x8) {
      __builtin_convertvector(__builtin_shufflevector(a, a, 0, 2, 4, 6, 8, 10,
12, 14), u16x8) +
      __builtin_convertvector(__builtin_shufflevector(a, a, 1, 3, 5, 7, 9, 11,
13, 15), u16x8)  
    };
}

u32x4
u16x8_extadd_pairwise(i16x8 a) {
    return (u32x4) {
      __builtin_convertvector(__builtin_shufflevector(a, a, 0, 2, 4, 6), u32x4)
+
      __builtin_convertvector(__builtin_shufflevector(a, a, 1, 3, 5, 7), u32x4) 
    };
}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>