Issue 135353
Summary [clang] Clang is unable to generate maddubs_epi16 intrinsics.
Labels clang
Assignees
Reporter topitopotin
    Clang 20.1.0 is unable to generate `vpmaddubsw`. Tested with the following code stub on Compiler Explorer with compiling options `-O2 -march=znver4`

```c
#include <cstdint>

#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define CLIP(low,high,value) MAX((low),MIN((high),(value)))


void maddubs(const uint8_t* const __restrict in_a, const int8_t* const __restrict in_b, int16_t* __restrict result)
{  
  int d = 64;
  for (int i = 0, dst = 0; i < d; i += 2, dst++){
    result[dst] = CLIP(INT16_MIN, INT16_MAX, (in_a[i + 0] * in_b[i + 0] + in_a[i + 1] * in_b[i + 1]));
  }
}

void madd(const int16_t* const __restrict in_a, const int16_t* const __restrict in_b, int32_t* __restrict result)
{  
  int d = 32;
  for (int i = 0, dst = 0; i < d; i += 2, dst++){
    result[dst] = CLIP(INT32_MIN, INT32_MAX, (in_a[i + 0] * in_b[i + 0] + in_a[i + 1] * in_b[i + 1]));
  }
}
```
The madd function vectorizes properly with `vpmaddwd` as expected.
https://godbolt.org/z/fMdcP8hjP
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to