https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118132
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Known to work| |12.1.0 Status|UNCONFIRMED |RESOLVED Known to fail| |11.4.0 Target Milestone|--- |12.0 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So the options needed are `-O3 -fPIE`. GCC 12 produces: _Z16GetDispatchTablev: .LFB16: .cfi_startproc movzx eax, BYTE PTR _ZGVZ16GetDispatchTablevE2_v[rip] test al, al je .L18 mov rax, QWORD PTR _ZZ16GetDispatchTablevE2_v[rip] ret Which is perfect. Fixed by r12-897-gde56f95afaaa22 which adds a sink pass after vectorization .