https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115454
Matthias Kretz (Vir) <mkretz at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2024-06-13 Assignee|unassigned at gcc dot gnu.org |mkretz at gcc dot gnu.org --- Comment #1 from Matthias Kretz (Vir) <mkretz at gcc dot gnu.org> --- Confirmed. The != compare returns an 8-bit mask (internally) for a 4-element simd_mask in https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/experimental/bits/simd_x86.h;h=4ab933b573c614654902d6f5747d53e39f4b100f;hb=HEAD#l2350. The high 4 bits are incorrectly set because of the ~ operator on the resulting mask. Those bits are not cleared before calling std::bit_width - 1, which is why the result is unconditionally 7. You can work around the bug by replacing 'e != -1' with '!(e == -1)' for the time being.