https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43491
Bill Schmidt <wschmidt at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target|arm-none-eabi |arm-none-eabi, powerpc*-*-* CC| |wschmidt at gcc dot gnu.org --- Comment #10 from Bill Schmidt <wschmidt at gcc dot gnu.org> --- This remains a problem and was rediscovered recently here with GCC 10. However, it seems worse than before in that conditions "c" and "d" of the original bug report are no longer necessary to get the unnecessary temporary. /* test case */ struct foo { int bar; int baz; }; register struct foo *local asm("r13"); void fn(void) { if (local->bar) local->bar = 0; local->baz--; } /* end test case */ Compile with -O2. As in the other case, the copy-to-temporary is introduced at gimplification and remains in place at expand time. wschmidt@marlin:~/src$ cat nick2.c.005t.gimple fn () { local.0_1 = local; _2 = local.0_1->bar; if (_2 != 0) goto <D.2840>; else goto <D.2841>; <D.2840>: local.1_3 = local; local.1_3->bar = 0; <D.2841>: local.2_4 = local; _5 = local.2_4->baz; _6 = _5 + -1; local.2_4->baz = _6; } wschmidt@marlin:~/src$ cat nick2.c.231t.optimized ;; Function fn (fn, funcdef_no=0, decl_uid=2837, cgraph_uid=1, symbol_order=1) Removing basic block 5 fn () { struct foo * local.0_1; int _2; int _5; int _6; <bb 2> [local count: 1073741824]: local.0_1 = local; _2 = local.0_1->bar; if (_2 != 0) goto <bb 3>; [50.00%] else goto <bb 4>; [50.00%] <bb 3> [local count: 536870913]: local.0_1->bar = 0; <bb 4> [local count: 1073741824]: _5 = local.0_1->baz; _6 = _5 + -1; local.0_1->baz = _6; return; }