https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118072
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2024-12-16 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So the middle-end is what decides based on costs. And the middle-end caches the decision. I wonder in the case of mod, it decides to use udiv but does not caches that and then divides comes along and decides to use multiply wise and caches that and then all future mods uses multiply case. That is take: ``` unsigned mod7(unsigned n) { return n % 7; } unsigned div7(unsigned n) { return n / 7; } unsigned mod7_1(unsigned n) { return n % 7; } ``` You can see the issue at hand.