https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118345
Bug ID: 118345
Summary: GCC produces no such instruction: `vmovw %xmm0,%xmm1'
for `-O1 -march=emeraldrapids`
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: wangbopku15 at gmail dot com
Target Milestone: ---
GCC 14.2.0 produces the following error:
The minimized bug-triggering code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <memory>
struct a {
char b;
};
class c {
public:
long d;
char e;
unsigned g;
bool h;
};
class i {
public:
int j;
};
void func(char k, int l, int m, unsigned n, int p, a *o, c r, i *s,
short q[][4][4]) {
for (short t = k - 5; t < 0; t += l)
for (short u = 0; u < m - 9; u += 4)
for (char v = 0; v < 014; v++)
for (unsigned w = 0; w < r.g - 3; w += p) {
std::max((short)r.e, (short)8);
if (std::min((unsigned short)1, (unsigned short)k)
? std::min(n, (unsigned)q[u][u][u])
: l)
o->b = r.d;
s->j = n;
}
for (int x = 0; x < 2047697976ULL; x = r.e)
k = 0;
}
int main(){ return 0; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The compile commands, note that if we remove -O1 or replace it with -O2, the
error disappears:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ g++ -O1 -march=emeraldrapids -c test.cpp
/tmp/ccXGIjL6.s: Assembler messages:
/tmp/ccXGIjL6.s:93: Error: no such instruction: `vmovw %xmm0,%eax'
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/user/compilers/gcc-14.2.0/libexec/gcc/x86_64-pc-linux-gnu/14.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/user/compilers/gcc-14.2.0
-enable-languages=c,c++ -disable-multilib --enable-checking=all
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.2.0 (GCC)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Additionally, I found a similar issue:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105139
The potential reason that the assembler rejects it may be the line `e2: vmovw
eax,xmm0` of the assembly program, shown as https://godbolt.org/z/qWMM14YfT