https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108401
Hongtao.liu <crazylht at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |crazylht at gmail dot com --- Comment #3 from Hongtao.liu <crazylht at gmail dot com> --- > and gcc 12 generates a worse code: > > movabs rax, 71777214294589695 > vmovq xmm1, rax > vpbroadcastq ymm0, xmm1 > ret > It's on purpose by edafb35bdadf309ebb9d1eddc5549f9e1ad49c09 since microbenchmark shows moving from imm is faster than memory. > In all cases, the compiler flags are: -O3 -march=haswell > > Code on godbolt.org: https://gcc.godbolt.org/z/sfT787PY9 > > I think the compiler should follow the code in intrinsics more closely since > despite the apparent equivalence, the choice of instructions can have > performance implications. The original code that is written by the developer > is better anyway, so it's not clear why the compiler is being so creative in > this case.