[Bug tree-optimization/79578] Unnecessary instructions in generated code
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79578 --- Comment #8 from Jeffrey A. Law --- Author: law Date: Thu Feb 23 21:43:03 2017 New Revision: 245688 URL: https://gcc.gnu.org/viewcvs?rev=245688=gcc=rev Log: PR tree-optimization/79578 * tree-ssa-dse.c (clear_bytes_written_by): Use OEP_ADDRESS_OF in call to operand_equal_p. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-ssa-dse.c
[Bug tree-optimization/79578] Unnecessary instructions in generated code
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79578 Jeffrey A. Law changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #7 from Jeffrey A. Law --- Fixed on the trunk.
[Bug tree-optimization/79578] Unnecessary instructions in generated code
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79578 --- Comment #6 from Jeffrey A. Law --- Author: law Date: Thu Feb 23 05:47:43 2017 New Revision: 245675 URL: https://gcc.gnu.org/viewcvs?rev=245675=gcc=rev Log: PR tree-optimization/79578 * tree-ssa-dse.c (clear_bytes_written_by): Use operand_equal_p to compare base operands. PR tree-optimization/79578 * g++.dg/tree-ssa/ssa-dse-3.C: New test. Added: trunk/gcc/testsuite/g++.dg/tree-ssa/ssa-dse-3.C Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-dse.c
[Bug tree-optimization/79578] Unnecessary instructions in generated code
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79578 Jeffrey A. Law changed: What|Removed |Added CC||law at redhat dot com --- Comment #5 from Jeffrey A. Law --- So at the first DSE pass the IL looks like: ;; basic block 2, loop depth 0 ;;pred: ENTRY if (b_3(D) != 0B) goto ; [0.00%] else goto ; [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
[Bug tree-optimization/79578] Unnecessary instructions in generated code
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79578 --- Comment #4 from Jonathan Wakely --- Since the check comes from the front-end, and the DR says it's not needed, maybe this belongs to component c++ not tree-optimization. If the front-end didn't insert the check we wouldn't need to optimize it away.
[Bug tree-optimization/79578] Unnecessary instructions in generated code
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79578 --- Comment #3 from Jonathan Wakely --- (In reply to Maxim Egorushkin from comment #0) > 2. The code assigns through that pointer, so the pointer must be valid. > Therefore there is no need to test the result of new for 0. In any case, we fixed the standard so that it's undefined to pass null to the placement new operator, so the check should never happen now, without needing to see the origin of the pointer or whether it is subsequently derferenced. http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1748 (See also PR 35878 comment 2)
[Bug tree-optimization/79578] Unnecessary instructions in generated code
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79578 Richard Biener changed: What|Removed |Added Keywords||missed-optimization Target||x86_64-*-*, i?86-*-* Status|UNCONFIRMED |NEW Last reconfirmed||2017-02-17 CC||law at gcc dot gnu.org Component|c++ |tree-optimization Ever confirmed|0 |1 --- Comment #2 from Richard Biener --- Note that appearantly b is allowed to be NULL. Confirmed for the partial dead code elimination issue. tree DSE sees [100.00%]: if (b_3(D) != 0B) goto ; [0.00%] else goto ; [0.00%] [0.00%]: MEM[(struct A *)b_3(D)] = {}; [0.00%]: MEM[(struct A *)b_3(D)].a = 1; MEM[(struct A *)b_3(D)].b = 2; return b_3(D); and after store-merging we have (no further DSE): [100.00%]: if (b_2(D) != 0B) goto ; [73.26%] else goto ; [26.74%] [73.26%]: MEM[(struct A *)b_2(D)] = {}; [100.00%]: MEM[(short unsigned int *)b_2(D)] = 131073; return b_2(D); Jeff -- wasn't your "partial DSE" supposed to help here? Ah, it was to trim partial stores rather than full stores followed by partial ones making it dead?