[Bug middle-end/53844] [4.6/4.7 Regression] GCC generates suboptimal code for unused members of classes in some cases on multiple targets.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53844 Richard Biener changed: What|Removed |Added Known to work|4.7.3 | Target Milestone|4.7.3 |4.8.0 Summary|[4.6 Regression] GCC|[4.6/4.7 Regression] GCC |generates suboptimal code |generates suboptimal code |for unused members of |for unused members of |classes in some cases on|classes in some cases on |multiple targets. |multiple targets. --- Comment #15 from Richard Biener 2013-02-18 13:47:33 UTC --- Reverted even on the 4.7 branch. Fixed for 4.8.
[Bug middle-end/53844] [4.6/4.7 Regression] GCC generates suboptimal code for unused members of classes in some cases on multiple targets.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53844 --- Comment #12 from Richard Biener 2013-02-04 12:04:42 UTC --- Author: rguenth Date: Mon Feb 4 12:04:35 2013 New Revision: 195708 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195708 Log: 2013-02-04 Richard Biener Backport from mainline 2012-07-04 Richard Guenther PR tree-optimization/53844 * tree-ssa-dse.c (dse_possible_dead_store_p): Properly handle the loop virtual PHI. * g++.dg/tree-ssa/pr53844.C: New testcase. 2012-12-13 Richard Biener PR lto/55660 * tree-streamer.c (record_common_node): Check that we are not recursively pre-loading nodes we want to skip. Handle char_type_node appearing as part of va_list_type_node. * gcc.dg/lto/pr55660_0.c: New testcase. * gcc.dg/lto/pr55660_1.c: Likewise. 2013-02-04 Richard Biener PR middle-end/55890 * gimple.h (gimple_call_builtin_class_p): New function. * gimple.c (validate_call): New function. (gimple_call_builtin_class_p): Likewise. * tree-ssa-structalias.c (find_func_aliases_for_builtin_call): Use gimple_call_builtin_class_p. (find_func_clobbers): Likewise. * tree-ssa-strlen.c (adjust_last_stmt): Likewise. (strlen_optimize_stmt): Likewise. * gcc.dg/torture/pr55890-1.c: New testcase. * gcc.dg/torture/pr55890-2.c: Likewise. Added: branches/gcc-4_7-branch/gcc/testsuite/g++.dg/tree-ssa/pr53844.C branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/lto/pr55660_0.c branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/lto/pr55660_1.c branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/pr55890-1.c branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/pr55890-2.c Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/gimple.c branches/gcc-4_7-branch/gcc/gimple.h branches/gcc-4_7-branch/gcc/testsuite/ChangeLog branches/gcc-4_7-branch/gcc/tree-ssa-dse.c branches/gcc-4_7-branch/gcc/tree-ssa-strlen.c branches/gcc-4_7-branch/gcc/tree-ssa-structalias.c branches/gcc-4_7-branch/gcc/tree-streamer.c
[Bug middle-end/53844] [4.6/4.7 Regression] GCC generates suboptimal code for unused members of classes in some cases on multiple targets.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53844 Richard Guenther changed: What|Removed |Added Priority|P3 |P2
[Bug middle-end/53844] [4.6/4.7 Regression] GCC generates suboptimal code for unused members of classes in some cases on multiple targets.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53844 --- Comment #11 from Edward Rosten 2012-07-04 14:13:28 UTC --- (In reply to comment #10) > On Wed, 4 Jul 2012, ed at edrosten dot com wrote: > here D.2391 is already dead. So possibly you are returning references > to temporaries somewhere. You are correct. In fiddling around adding and removing &'s and not tracking my files properly, I left some references in. If I do it properly, then good code is produced.
[Bug middle-end/53844] [4.6/4.7 Regression] GCC generates suboptimal code for unused members of classes in some cases on multiple targets.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53844 --- Comment #10 from rguenther at suse dot de 2012-07-04 13:47:09 UTC --- On Wed, 4 Jul 2012, ed at edrosten dot com wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53844 > > Edward Rosten changed: > >What|Removed |Added > > Component|tree-optimization |middle-end > > --- Comment #8 from Edward Rosten 2012-07-04 > 13:36:28 UTC --- > (In reply to comment #7) > > Fixed on trunk sofar, watching for fallout. > > I pulled the latest change from SVN and tried it on the test code, with > success. > > I'm using the shortened test function: > > > void test(const Vector<>& in, Vector<>& out, int i) > { > out = in*1*1*1*1; > } > > If I change the test function to: > > > void test(const Vector<>& in, Vector<>& out, int i) > { > const > Vector > > > > >& v = in*1*1*1*1; > out = v; > } I can at least see that you are using no longer live variables: : D.2391 ={v} {CLOBBER}; D.2396 ={v} {CLOBBER}; : # i_36 = PHI D.2928_28 = MEM[(struct VBase *)out_3(D)].my_data; D.2929_30 = (long unsigned int) i_36; D.2930_31 = D.2929_30 * 8; D.2927_32 = D.2928_28 + D.2930_31; D.2948_44 = MEM[(const struct ScalarMulExpr *)&D.2391].vec; here D.2391 is already dead. So possibly you are returning references to temporaries somewhere.
[Bug middle-end/53844] [4.6/4.7 Regression] GCC generates suboptimal code for unused members of classes in some cases on multiple targets.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53844 --- Comment #9 from Edward Rosten 2012-07-04 13:40:54 UTC --- (In reply to comment #7) > Fixed on trunk sofar, watching for fallout. I would like to note that your fix seems to remove the performance hit in my numerics which revealed the bug.
[Bug middle-end/53844] [4.6/4.7 Regression] GCC generates suboptimal code for unused members of classes in some cases on multiple targets.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53844 Edward Rosten changed: What|Removed |Added Component|tree-optimization |middle-end --- Comment #8 from Edward Rosten 2012-07-04 13:36:28 UTC --- (In reply to comment #7) > Fixed on trunk sofar, watching for fallout. I pulled the latest change from SVN and tried it on the test code, with success. I'm using the shortened test function: void test(const Vector<>& in, Vector<>& out, int i) { out = in*1*1*1*1; } If I change the test function to: void test(const Vector<>& in, Vector<>& out, int i) { const Vector > > > >& v = in*1*1*1*1; out = v; } The the results go to being almost identical to gcc 4.7 (and much worse than the first test function). The asm code (compiled with -fno-tree-vectorize to avoid all the asm code to deal with alignment etc) gives: _Z4testRK6VectorI5VBaseERS1_i: .LFB8: .cfi_startproc movq(%rsi), %rcx xorl%esi, %esi movq-16(%rsp), %rax cvtsi2sd%esi, %xmm1 movq8(%rax), %rdx movq(%rax), %rax cvtsi2sd(%rax), %xmm3 movq-24(%rsp), %rax movq(%rdx), %rdx cvtsi2sd(%rax), %xmm2 xorl%eax, %eax .p2align 4,,10 .p2align 3 .L3: movsd(%rdx,%rax), %xmm0 mulsd%xmm3, %xmm0 mulsd%xmm2, %xmm0 mulsd%xmm1, %xmm0 movsd%xmm0, (%rcx,%rax) addq$8, %rax cmpq$800, %rax jne.L3 rep; ret .cfi_endproc In this case, it's clearly converting all those 1's to floats and then multiplying by all but the first one. Note that if the following test function is used: void test(const Vector<>& in, Vector<>& out, int i) { const Vector > >& v = in*1*1; out = v; } Then suboptimal code isn't produced. Further investigation shows that this also applies to the previous symptom with unnecessary pushes in gcc 4.7. If I change the mul member in ScalarMulExpr to int rather than int&, the compiler can optimize away the first two multiplications, rather than the first one. GCC version is: gcc-4.8-svn -v Using built-in specs. COLLECT_GCC=gcc-4.8-svn COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc/configure --program-suffix=-4.8-svn --enable-languages=c,c++ Thread model: posix gcc version 4.8.0 20120704 (experimental) (GCC) but similar results are reported on 4.7 as well. Is this a continuation of the same bug, or should I refile this as a new bug?
[Bug middle-end/53844] [4.6/4.7 Regression] GCC generates suboptimal code for unused members of classes in some cases on multiple targets.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53844 Andrew Pinski changed: What|Removed |Added Known to work||4.3.3 Target Milestone|--- |4.6.4 Summary|GCC generates suboptimal|[4.6/4.7 Regression] GCC |code for unused members of |generates suboptimal code |classes in some cases on|for unused members of |multiple targets. |classes in some cases on ||multiple targets. Severity|enhancement |normal --- Comment #2 from Andrew Pinski 2012-07-03 20:26:46 UTC --- DCE used to be able to remove these stores at least in 4.3.3.