[Bug tree-optimization/79578] Unnecessary instructions in generated code
law at redhat dot com
gcc-bugzilla@gcc.gnu.org
Fri Feb 17 16:02:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79578
Jeffrey A. Law <law at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |law at redhat dot com
--- Comment #5 from Jeffrey A. Law <law at redhat dot com> ---
So at the first DSE pass the IL looks like:
;; basic block 2, loop depth 0
;; pred: ENTRY
if (b_3(D) != 0B)
goto <bb 3>; [0.00%]
else
goto <bb 4>; [0.00%]
;; succ: 3
;; 4
;; basic block 3, loop depth 0
;; pred: 2
# .MEM_9 = VDEF <.MEM_5(D)>
MEM[(struct A *)b_3(D)] = {};
;; succ: 4
;; basic block 4, loop depth 0
;; pred: 3
;; 2
# .MEM_2 = PHI <.MEM_9(3), .MEM_5(D)(2)>
# .MEM_12 = VDEF <.MEM_2>
MEM[(struct A *)b_3(D)].a = 1;
# .MEM_13 = VDEF <.MEM_12>
MEM[(struct A *)b_3(D)].b = 2;
# VUSE <.MEM_13>
return b_3(D);
;; succ: EXIT
The initialization looks like a fully dead store to me. And it is. The reason
it's not caught is we currently require pointer equality on the address
expression. Using operand_equal_p instead results in the initialization being
eliminated by DSE1. I think the only question is whether or not to fix this
during stage4 or wait for gcc-8. It's a 1-liner ;-)
Of course once the dead store is gone BB3 is pointless and we can eliminate the
test resulting in:
movq %rdi, %rax
movl $131073, (%rdi)
ret
More information about the Gcc-bugs
mailing list