<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/61807>61807</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Importing a C++ module causes simd matrix operators to disappear
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rnikander
      </td>
    </tr>
</table>

<pre>
    Started in this issue here: https://github.com/llvm/llvm-project/issues/61493. Per request I'm filing another one with headers stripped down. 

The types in Apple's `<simd/simd.h>` header do not seem to work well with C++ modules. Below you will see that there are operators defined, like `operator *`, but they become unavailable when you `import` the module. 

I replaced a function implementation with `throw 1` to avoid pulling on the thread and including a lot more stuff. 

`header.h`
```c++
// This file is #include <simd/simd.h> stripped down to the just enough to reproduce the issue.

typedef __attribute__((__ext_vector_type__(2))) float simd_float2;

typedef struct { simd_float2 columns[2]; } simd_float2x2;

extern "C" {
static  simd_float2 simd_mul( simd_float2x2 __x,  simd_float2 __y) { throw 1; }
}

namespace simd {

typedef ::simd_float2 float2;
  
struct float2x2 : ::simd_float2x2 {
    float2x2() { columns[0] = 0; columns[1] = 0; }
    float2x2(float2 v) { columns[0] = (float2){v.x,0}; columns[1] = (float2){0,v.y}; }
    float2x2(float2 c0, float2 c1) { columns[0] = c0; columns[1] = c1; }
    float2x2(::simd_float2x2 m) : ::simd_float2x2(m) { }
};

static float2 operator*(const float2x2 x, const float2 y) { return ::simd_mul(x, y); }
}
```

`ModWithVectors_min.cc`
```c++
module;
#include "header.h"
export module ModWithVectors;
```

`main_min.cc`
```c++

#include "header_here.h"

import ModWithVectors; // Comment this out and it compiles.

int main(int argc, char *argv[])
{
    //  ⎡ 1 2 ⎤ * ⎡1⎤ = ⎡5⎤
    //  ⎣ 3 4 ⎦   ⎣2⎦   ⎣1⎦
    simd::float2 col1{1, 3};
    simd::float2 col2{2, 4};    
    simd::float2x2 mat(col1, col2);
    simd::float2 vec{1, 2};
    auto v = mat * vec;
    return 0;
}
```

CMakeLists.txt

```text
add_executable(mod_bug3_min)
target_sources(mod_bug3_min
  PUBLIC  main_min.cc
  PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES ModWithVectors_min.cc
)
```

The error:

```text
/ModBug3/main_min.cc:14:18: error: cannot convert between vector and non-scalar values ('simd::float2x2' and 'simd::float2' (aka 'simd_float2'))
    auto v = mat * vec;
             ~~~ ^ ~~~
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykV02P4jwS_jXmUnpR4vARDhz4lFrq1o7UPbuzp8g4BfG0Y2dtB-jL_PaVnRACQ_fs6kUoH3a56qnyU-UKs1YcFOKcjJdkvB6w2hXazI0S70zlaAY7nX_MXx0zDnMQClwhLAhra4QCDZJkAYVzlSXJgtAtoduDcEW9G3JdErqV8ni5_VUZ_RO5I3QblltCt5N4NEuG8A0NGPxPjdbBE6HTEvZCCnUAprQr0IBWCCfhCiiQ5WgsWGdEVWEOuT6pIZBoTaJFc30rENxHhdajXVSVREKnFsgkIsnKijIndOtvw4IkGzKJWp2Qa1DagUUswWk4afMOJ5SyMbwidEnoEkqd1xLtEJYo9Qk-dA0nIaVfBq5gDjxeBGYQdIWGOW0s5LgXCnNCVyDFO3osl0kgdOGh0RXs6rD6A3bIdYlQK3ZkQrKdRDgVqIIxMolEWWnjPHJXYAvoNgRPYLCSjGMODPa14k5oBaKsJJaoHAuvwS0yiVxh9AnioE8DO2qRQ1XLEH-tgg1XGGQ5MOUZwGWdh70BqR2U2iBYV-_3txDIJGriOiy8e5ex5s-bYLajgTXw5nm1FxJBWCA0aQwhPNi02933qD3In7V1gErXh8IPGayMzmuOYTIwbtgH6CmS4x6yjDlnxK52mGWEpoSmWYZnlx2RO20yLxcmKKGz5g97qZkDjycLj5Qky0e6rTM1d0Cmy74wcC3rUlkyXlIyXpNkCWS67kuc7xXi2aFRQChdEUq9wmbc-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