https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108992
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #7) > (In reply to Nikita Kniazev from comment #6) > > The duplication happens even if I make cond int and compare with any other > > value > > > > void use(int *); > > void use2(int *); > > > > void foo(int * p, int cond) > > { > > if (cond == 789) { > > use(p); > > } > > use2(p); > > } > > Yes and no, Yes it does in GCC 7/8 but starting in GCC 9 there is not. > GCC before GCC 10.x is no longer supported so there is not much we can do > there. Well actually I was wrong, the duplication is there but you can see why GCC does the code duplication really. To also do shrink wrapping. That is GCC 9+ does not need to setup a stack frame for the != 789 case and just tail call to use2.