https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94343
Bug ID: 94343
Summary: [10 Regression] invalid AVX512VL vpternlogd
instruction emitted for -march=knl
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: missed-optimization, wrong-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: kretz at kde dot org
Target Milestone: ---
Target: i386,x86-64
Test case (`-O1 -march=knl`, cf. https://godbolt.org/z/qQc3Sf):
using W [[gnu::vector_size(16)]] = long long;
using V [[gnu::vector_size(16)]] = int;
auto f(V a) {
return __builtin_ia32_pandn128(reinterpret_cast<W>(~V() ^ a), ~W());
}
This emits a XMM variant of `vpternlogd` which requires AVX512VL. But it was
supposed to compile for KNL.
Besides the bug, there's also a missed optimization here: `~V() ^ a` flips all
bits and pandn flips all bits again. Thus it should compile to a single `ret`
instruction. Note that the variation:
auto f(V a) {
return ~reinterpret_cast<W>(~V() ^ a) & ~W();
}
compiles to
vpternlogd xmm0, xmm0, xmm0, 0x55
vpternlogq xmm0, xmm0, xmm0, 0x55
for KNL.