[Bug tree-optimization/43629] [4.3/4.4 Regression] Struct to register optimization fails

2010-04-02 Thread rguenth at gcc dot gnu dot org


--- Comment #1 from rguenth at gcc dot gnu dot org  2010-04-02 11:31 ---
Confirmed.  Yet another SRA to bitfield magic issue.

Workaround: -fno-tree-sra.

struct A {
   short A1 ;
   short A2 ;
   int   A3 ;
};

static struct A __attribute__((noinline))
foo(int b)
{
   struct A result;
   result.A1 = (short)0;
   result.A2 = (short)0;
   /* result.A3 is intentionally not initialized */
   if (b) {
  result.A1 = (short)1;
  result.A2 = (short)2;
  result.A3 = 3;
  return result;
   }
   return result;
}

extern void abort (void);

int main()
{
  struct A myA = foo(0);
  if (myA.A1 != 0)
abort ();
  return 0;
}


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
  Component|c   |tree-optimization
 Ever Confirmed|0   |1
   Keywords||wrong-code
  Known to fail||4.3.0 4.3.4 4.4.0 4.4.3
  Known to work||4.2.4 4.5.0
   Last reconfirmed|-00-00 00:00:00 |2010-04-02 11:31:52
   date||
Summary|Struct to register  |[4.3/4.4 Regression] Struct
   |optimization fails  |to register optimization
   ||fails
   Target Milestone|--- |4.3.5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43629



[Bug tree-optimization/43629] [4.3/4.4 Regression] Struct to register optimization fails

2010-04-02 Thread rguenth at gcc dot gnu dot org


--- Comment #2 from rguenth at gcc dot gnu dot org  2010-04-02 11:47 ---
SRA introduces a use of the uninitialized value when re-constructing the
unsigned long representation.  That boils down to later CCP recognizing
the result as undefined and thus:

Visiting statement:
SR.16_25 = (unsigned int) result$A3_24(D);
which is likely UNDEFINED

Visiting statement:
SR.17_26 = (long unsigned int) SR.16_25;
which is likely UNDEFINED

Visiting statement:
SR.18_27 = SR.17_26 << 32;
which is likely UNDEFINED

Visiting statement:
SR.3_34 = SR.18_27 & 0x0;
which is likely UNDEFINED

Visiting PHI node: SR.3_2 = PHI <12885032961(2), SR.3_34(3)>

Argument #0 (2 -> 4 executable)
12885032961 Value: CONSTANT 12885032961

Argument #1 (3 -> 4 executable)
SR.3_34 Value: UNDEFINED

PHI node value: CONSTANT 12885032961

Lattice value changed to CONSTANT 12885032961.


and we completely ignore the taken path.

One issue is that

Visiting statement:
SR.3_34 = SR.18_27 & 0x0;
which is likely UNDEFINED

is not 100% true - the value is only partially undefined (only the defined
pieces will be used later).  But of course that's splitting hairs somewhat
(but it might be the easiest fix for this bug).

tree-ssa-ccp.c:likely_value needs to look at regular rhs operands for
literal constants (see trunk version) but also make sure to re-set
all_undefined_operands if it encounters such.


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
   |dot org |org
 Status|NEW |ASSIGNED
   Last reconfirmed|2010-04-02 11:31:52 |2010-04-02 11:47:23
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43629



[Bug tree-optimization/43629] [4.3/4.4 Regression] Struct to register optimization fails

2010-04-02 Thread rguenth at gcc dot gnu dot org


--- Comment #7 from rguenth at gcc dot gnu dot org  2010-04-02 16:50 ---
Fixed for 4.5 sofar.


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

  Known to fail|4.3.0 4.3.4 4.4.0 4.4.3 |4.3.0 4.3.4 4.4.0 4.4.3
   |4.5.0   |
  Known to work|4.2.4   |4.2.4 4.5.0
Summary|[4.3/4.4/4.5 Regression]|[4.3/4.4 Regression] Struct
   |Struct to register  |to register optimization
   |optimization fails  |fails


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43629



[Bug tree-optimization/43629] [4.3/4.4 Regression] Struct to register optimization fails

2010-04-02 Thread julien dot etienne at gmail dot com


--- Comment #8 from julien dot etienne at gmail dot com  2010-04-02 20:12 
---
Thanks for your help.
I will try the 4.5.0 version as soon as I can access svn.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43629



[Bug tree-optimization/43629] [4.3/4.4 Regression] Struct to register optimization fails

2010-04-03 Thread mikpe at it dot uu dot se


--- Comment #9 from mikpe at it dot uu dot se  2010-04-03 19:38 ---
For 4.4 the test cases (both the original struct-using one and the later
integer-only one) are fixed by backporting r145184 (PR38180 fix) and then
r157944.  Either of them alone fixes neither test case.  Bootstrapped and
regression tested on x86_64-linux so far.


-- 

mikpe at it dot uu dot se changed:

   What|Removed |Added

 CC||mikpe at it dot uu dot se


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43629



[Bug tree-optimization/43629] [4.3/4.4 Regression] Struct to register optimization fails

2010-04-03 Thread rguenth at gcc dot gnu dot org


--- Comment #10 from rguenth at gcc dot gnu dot org  2010-04-03 19:53 
---
(In reply to comment #9)
> For 4.4 the test cases (both the original struct-using one and the later
> integer-only one) are fixed by backporting r145184 (PR38180 fix) and then
> r157944.  Either of them alone fixes neither test case.  Bootstrapped and
> regression tested on x86_64-linux so far.

It only needs the likely_value changes backported (for 4.3 they need to
be adjusted to match the pre-tuples world).  I will do the backports once
4.5.0 is out of the door.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43629



[Bug tree-optimization/43629] [4.3/4.4 Regression] Struct to register optimization fails

2010-04-07 Thread rguenth at gcc dot gnu dot org


--- Comment #11 from rguenth at gcc dot gnu dot org  2010-04-07 15:41 
---
Subject: Bug 43629

Author: rguenth
Date: Wed Apr  7 15:40:43 2010
New Revision: 158070

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158070
Log:
2010-04-07  Richard Guenther  

PR tree-optimization/43629
* tree-ssa-ccp.c (likely_value): Properly look for constant
values.  Reset all_undefined_operands if we have seen a
constant value.

* gcc.c-torture/execute/pr43629.c: New testcase.

Added:
branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr43629.c
Modified:
branches/gcc-4_4-branch/gcc/ChangeLog
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
branches/gcc-4_4-branch/gcc/tree-ssa-ccp.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43629