https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111799
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Component|tree-optimization |middle-end Ever confirmed|0 |1 Keywords| |TREE Last reconfirmed| |2023-10-18 --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Theodoros Theodoridis from comment #4) > Oops, there was a bug in my reduction, here's the fixed code: > > https://godbolt.org/z/shxffzs8E > > void foo(void); > typedef unsigned short uint16_t; > static int b; > static int ****c; > static int *f = &b; > static int *****ad; > static char(a)(char g, char h) { return g + h; } > static char(d)(char g, char h) { return g * h; } > static void(e)(uint16_t g) { > if (!(((g) >= 1) && ((g) <= 65459))) { > __builtin_unreachable(); > } > } > int main() { > b = 0; > for (;; b = 1) { > char i = d(126 | 1, 205); > e(i); > short j; > int k = *f; > j = -21; > for (; j; j = a(j, 7)) e((j ^ k && *f) <= *f); > if (b) break; > ad = &c; > } > if (ad) > ; > else > foo(); > ; > } Confirmed with this testcase but what is interesting is that the optimization of calling foo away does NOT happen at the gimple level but at the RTL level and just happens on x86_64 but NOT on aarch64. on aarch64 for GCC 13, we even have: mov w0, 1 str wzr, [x1, #:lo12:.LANCHOR0] cbz w0, .L13 Which is obvious should have been removed ... Anyways this is a missed jump threading that should have happened at the gimple level. I have not looked into why it is not done.