Bug 22157

Summary: [4.0/4.1 Regression] struct copying code gen
Product: gcc Reporter: Andrew Pinski <pinskia>
Component: tree-optimizationAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: gcc-bugs, pawel_sikora, rth
Priority: P2 Keywords: missed-optimization
Version: 4.1.0   
Target Milestone: 4.0.2   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2005-06-23 19:49:02
Bug Depends on: 14295, 18268    
Bug Blocks: 22156    

Description Andrew Pinski 2005-06-23 05:34:26 UTC
Take the following code:
struct s
{
  short t;
  short y1;
};

void f(struct s *x, struct s *y)
{
  struct s t = *x;
  *y = t;
}

In 3.4.0, we produced:
_f:
        lwz r0,0(r3)
        stw r0,0(r4)
        blr
but in 4.0.0 and above:
_f:
        lhz r2,2(r3)
        lha r0,0(r3)
        sth r2,2(r4)
        sth r0,0(r4)
        blr

I am starting to think we should use VIEW_CONVERT_EXPR in SRA and store it into a type which is the 
same as the mode if the mode is not BKL_MODE (RTL mode by the way) and we don't access the 
temporary variable's fields.  That would fix PR 22156 also.  Maybe I can look into doing this.
Comment 1 Andrew Pinski 2005-06-23 19:49:02 UTC
I have a fix, it does what I recommended.
Comment 2 Andrew Pinski 2005-07-04 10:26:12 UTC
I am no longer working on this, this is a much harder problem than I sugested.  This is basically the 
same as PR 18268.
Comment 3 Richard Biener 2005-09-15 09:46:04 UTC
Can you elaborate on why the VIEW_CONVERT_EXPR experiment failed and perhaps
attach the patch you tried?  Or does using VIEW_CONVERT_EXPR just expose that
we don't do structure propagation?
Comment 4 Andrew Pinski 2005-09-15 13:59:13 UTC
(In reply to comment #3)
> Can you elaborate on why the VIEW_CONVERT_EXPR experiment failed and perhaps
> attach the patch you tried?  Or does using VIEW_CONVERT_EXPR just expose that
> we don't do structure propagation?

VCE failed because it causes some missed optimizations and really just exposed the fact we don't have 
structure copy prop.
Comment 5 Andrew Pinski 2005-09-15 14:27:30 UTC
I am just going to mark this one as a dup of bug 22156, because it is the same problem, just different 
testcases.

*** This bug has been marked as a duplicate of 22156 ***