[Bug tree-optimization/70171] Poor code generated when return struct using ternary operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70171 Richard Biener changed: What|Removed |Added Status|ASSIGNED|RESOLVED Known to work||7.0 Resolution|--- |FIXED --- Comment #10 from Richard Biener --- Fixed for GCC 7.
[Bug tree-optimization/70171] Poor code generated when return struct using ternary operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70171 --- Comment #9 from Richard Biener --- Author: rguenth Date: Tue Apr 19 14:03:59 2016 New Revision: 235208 URL: https://gcc.gnu.org/viewcvs?rev=235208&root=gcc&view=rev Log: 2016-04-19 Richard Biener PR tree-optimization/70171 * tree-ssa-phiprop.c: Include stor-layout.h. (phiprop_insert_phi): Handle the aggregate copy case. (propagate_with_phi): Likewise. * g++.dg/tree-ssa/pr70171.C: New testcase. Added: trunk/gcc/testsuite/g++.dg/tree-ssa/pr70171.C Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-phiprop.c
[Bug tree-optimization/70171] Poor code generated when return struct using ternary operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70171 --- Comment #8 from Richard Biener --- (In reply to Oleg Endo from comment #7) > Is this a dup of PR 56365? Sounds like so ... No, not really.
[Bug tree-optimization/70171] Poor code generated when return struct using ternary operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70171 Oleg Endo changed: What|Removed |Added CC||olegendo at gcc dot gnu.org --- Comment #7 from Oleg Endo --- Is this a dup of PR 56365? Sounds like so ...
[Bug tree-optimization/70171] Poor code generated when return struct using ternary operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70171 --- Comment #6 from rguenther at suse dot de --- On Fri, 11 Mar 2016, ubizjak at gmail dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70171 > > --- Comment #5 from Uroš Bizjak --- > (In reply to Richard Biener from comment #4) > > Created attachment 37935 [details] > > patch > > > > Patch I am testing. > > + /* { dg-final { scan-assembler-not "\[er\]sp" { target x86_64-*-* } } } */ > > You should always use "target i?86-*-* x86_64-*-*" and optionally limit to > 64bit targets with "&& { ! ia32 }". Please see many examples in gcc.dg. Will do.
[Bug tree-optimization/70171] Poor code generated when return struct using ternary operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70171 --- Comment #5 from Uroš Bizjak --- (In reply to Richard Biener from comment #4) > Created attachment 37935 [details] > patch > > Patch I am testing. + /* { dg-final { scan-assembler-not "\[er\]sp" { target x86_64-*-* } } } */ You should always use "target i?86-*-* x86_64-*-*" and optionally limit to 64bit targets with "&& { ! ia32 }". Please see many examples in gcc.dg.
[Bug tree-optimization/70171] Poor code generated when return struct using ternary operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70171 --- Comment #4 from Richard Biener --- Created attachment 37935 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37935&action=edit patch Patch I am testing.
[Bug tree-optimization/70171] Poor code generated when return struct using ternary operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70171 Richard Biener changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment #3 from Richard Biener --- Btw, the C frontend produces optimized code here - it simply uses return select != 0 ? a : b; in its GENERIC. Maybe the C++ FE can avoid building a TARGET_EXPR like that or use return = TARGET_EXPR that is, without going through the address-taking and dereferencing game?
[Bug tree-optimization/70171] Poor code generated when return struct using ternary operator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70171 Richard Biener changed: What|Removed |Added Keywords||missed-optimization Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2016-03-11 Component|c++ |tree-optimization Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Richard Biener --- This is the C++ frontends work: ;; Function S struct_ternary(S, S, bool) (null) ;; enabled by -tree-original < = TARGET_EXPR >>; and while we have a pass that cleans this up for scalars it refuses to operate on aggregates (because it tries to use a PHI in the transform). Thus phiprop could handle this case emitting non-SSA code here and do this for aggregates with non-BLKmode. Basically transform : if (select_2(D) != 0) goto ; else goto ; : : # iftmp.1_1 = PHI <&a(2), &b(3)> D.2322 = MEM[(const struct S &)iftmp.1_1]; into : if (select_2(D) != 0) goto ; else goto ; : D.2322 = b; goto ; : D.2322 = a; : Let me try to tackle this for GCC 7.