https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108181
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2022-12-19 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- <bb 2> [local count: 1073741809]: switch (idx_13(D)) <default: <L40> [0.00%], case 0: <L42> [10.00%], case 1: <L43> [10.00%], case 2: <L44> [10.00%], case 3: <L45> [10.00%], case 4: <L46> [10.00%], case 5: <L47> [10.00%], case 6: <L48> [10.00%], case 7: <L49> [10.00%], case 8: <L50> [10.00%], case 9: <L51> [10.00%]> <bb 3> [local count: 107374182]: <L42>: _1 = MEM[(int (*) () * *)f_14(D)]; iftmp.0_43 = *_1; _45 = iftmp.0_43 (f_14(D)); [tail call] goto <bb 14>; [100.00%] <bb 4> [local count: 107374182]: <L43>: _2 = MEM[(int (*) () * *)f_14(D)]; iftmp.2_40 = MEM[(int (*) () *)_2 + 8B]; _42 = iftmp.2_40 (f_14(D)); [tail call] goto <bb 14>; [100.00%] So 3 things need to happen. First pulling out the load from f_14 (getting the vtable) out of the switch. And then pushing the call out of the switch. And then seeing the load that is left is idx_13(D) * 4. There are a few bugs for these things but I am not going to look for them right now.