NO

Author Topic: expected 'signed char' but found '__m128i'  (Read 1238 times)

Offline Robert

  • Member
  • *
  • Posts: 245
expected 'signed char' but found '__m128i'
« on: May 06, 2022, 06:38:33 AM »
Pelles C 11.00.2, This code

Code: [Select]
struct processed_utf_bytes previous = {.rawbytes = _mm_setzero_si128(),
                                       .high_nibbles = _mm_setzero_si128(),
                                       .carried_continuations =
                                           _mm_setzero_si128()};

is producing these errors

Code: [Select]
simdutf8check.h(162): error #2082: Invalid initialization type; expected 'signed char' but found '__m128i'.
simdutf8check.h(163): error #2082: Invalid initialization type; expected 'signed char' but found '__m128i'.
simdutf8check.h(165): error #2082: Invalid initialization type; expected 'signed char' but found '__m128i'.

where the struct members have been declared as

Code: [Select]
struct processed_utf_bytes {
  __m128i rawbytes;
  __m128i high_nibbles;
  __m128i carried_continuations;
};

in the attached file.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: expected 'signed char' but found '__m128i'
« Reply #1 on: May 06, 2022, 02:33:49 PM »
Pelles C 11.00.2, This code

Code: [Select]
struct processed_utf_bytes previous = {.rawbytes = _mm_setzero_si128(),
                                       .high_nibbles = _mm_setzero_si128(),
                                       .carried_continuations =
                                           _mm_setzero_si128()};

is producing these errors

Code: [Select]
simdutf8check.h(162): error #2082: Invalid initialization type; expected 'signed char' but found '__m128i'.
simdutf8check.h(163): error #2082: Invalid initialization type; expected 'signed char' but found '__m128i'.
simdutf8check.h(165): error #2082: Invalid initialization type; expected 'signed char' but found '__m128i'.
Apparently you can't call intrinsic function inside an initialization. Changing initialization to:
Code: [Select]
struct processed_utf_bytes previous;
previous.rawbytes = _mm_setzero_si128();
previous.high_nibbles = _mm_setzero_si128();
previous.carried_continuations = _mm_setzero_si128();
Seems to work.
Anyway there are still many warnings:
Code: [Select]
warning #2071: Overflow or truncation in constant expression.
« Last Edit: May 07, 2022, 10:29:36 AM by frankie »
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline Robert

  • Member
  • *
  • Posts: 245
Re: expected 'signed char' but found '__m128i'
« Reply #2 on: May 06, 2022, 08:37:58 PM »
Thanks frankie, that gives me a go ahead for now.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: expected 'signed char' but found '__m128i'
« Reply #3 on: May 08, 2022, 02:52:25 PM »
You're welcome Robert.
I made some more tests, specifically using the zero initialization for structures:
Code: [Select]
  struct processed_utf_bytes previous = {0};
This, as should be expected, works.
But compiling your header file triggers an internal compiler error:
Code: [Select]
fatal error: Internal error: cast_tree(#1).
Maybe Pelle can have a look on it.
On the other hand, using the same initialization in a simple program as below compiles and runs without errors:
Code: [Select]
#include <stdio.h>
#include <immintrin.h>

struct test__m128i
{
  __m128i rawbytes;
  __m128i high_nibbles;
  __m128i carried_continuations;
};

int main(int argc, char *argv[])
{
struct test__m128i t = {0};
printf("Hello World! %lld\n", *(long long int *)&t);
}
At this point is hard to say where the problem is, probably inside the compiler itself.
Let wait for Pelle...  :P
« Last Edit: May 08, 2022, 02:54:03 PM by frankie »
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: expected 'signed char' but found '__m128i'
« Reply #4 on: May 08, 2022, 06:52:37 PM »
Unfortunately you are allowed to initialize individual elements of a SIMD type with MSVC (it would have been much better if SIMD types always behaved like BLOBs, like in other compilers). This complicates parsing of initializers for SIMD types (with or without /Ze): it can be a SIMD, or a union of arrays with various scalar types and lengths.

The initializer parsing needs to be rewritten anyway, for other/better reasons than this, but this is going to take some considerable time...
/Pelle

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: expected 'signed char' but found '__m128i'
« Reply #5 on: May 08, 2022, 09:16:12 PM »
Thanks for explanation Pelle
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide