public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/26198]  New: Unfolded comparison after cfg_cleanup
@ 2006-02-09 15:41 rguenth at gcc dot gnu dot org
  2006-02-09 15:43 ` [Bug middle-end/26198] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-02-09 15:41 UTC (permalink / raw)
  To: gcc-bugs

struct A
{
  int* x[2];
  A() { for (int** p=x; p<x+2; ++p) *p = 0; }
};

struct B
{
  char c;
  A a0, a1, a2, a3, *p;

  B() {}
  B(const B& b) : c(), a0(b.a0), p(b.p) {}
  ~B() { delete p; }
};

inline void foo(const B& b) { new B(b); }

void bar()
{
  foo(B());
  foo(B());
}

After cfg_cleanup after loop header copying we end up with unfolded

  &D.2114.a0D.2019.xD.1986[2] > &D.2114.a0D.2019.xD.1986[0]

because in fold_binary where we handle this kind of stuff we have

              if (!offset0 || !offset1
                  || TREE_TYPE (offset0) == TREE_TYPE (offset1))
                {
...

and unfortunately the constants 2 and 0 have distinct types:

(gdb) call debug_tree(offset0)
 <integer_cst 0x4026e888 type <integer_type 0x402474ac> constant invariant 8>
(gdb) call debug_tree(offset1)
 <integer_cst 0x4018d180 type <integer_type 0x4019f000 unsigned int> constant
invariant 0>


-- 
           Summary: Unfolded comparison after cfg_cleanup
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/26198] Unfolded comparison after cfg_cleanup
  2006-02-09 15:41 [Bug middle-end/26198] New: Unfolded comparison after cfg_cleanup rguenth at gcc dot gnu dot org
@ 2006-02-09 15:43 ` pinskia at gcc dot gnu dot org
  2006-06-19 20:10 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-09 15:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-02-09 15:43 -------
Confirmed, this testcase is from PR 26197.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-02-09 15:43:14
               date|                            |


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/26198] Unfolded comparison after cfg_cleanup
  2006-02-09 15:41 [Bug middle-end/26198] New: Unfolded comparison after cfg_cleanup rguenth at gcc dot gnu dot org
  2006-02-09 15:43 ` [Bug middle-end/26198] " pinskia at gcc dot gnu dot org
@ 2006-06-19 20:10 ` rguenth at gcc dot gnu dot org
  2006-10-26  9:53 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-06-19 20:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2006-06-19 19:40 -------
Note that the reason mentioned was fixed recently, but we still have (in
.optimized):

<L18>:;
  p = &D.2217->a2.x[0];
  D.2237 = &D.2217->a2.x[2];
  if (p < D.2237) goto <L19>; else goto <L21>;

...

<L21>:;
  p = &D.2217->a3.x[0];
  D.2243 = &D.2217->a3.x[2];
  if (p < D.2243) goto <L22>; else goto <L24>;


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/26198] Unfolded comparison after cfg_cleanup
  2006-02-09 15:41 [Bug middle-end/26198] New: Unfolded comparison after cfg_cleanup rguenth at gcc dot gnu dot org
  2006-02-09 15:43 ` [Bug middle-end/26198] " pinskia at gcc dot gnu dot org
  2006-06-19 20:10 ` rguenth at gcc dot gnu dot org
@ 2006-10-26  9:53 ` rguenth at gcc dot gnu dot org
  2007-03-05 17:07 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-10-26  9:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2006-10-26 09:53 -------
And note that before TER we have

  p_108 = &this_91->a3.x[0];
  D.3632_327 = p_108 + 15B;
  if (p_108 <= D.3632_327) goto <L203>; else goto <L47>;

it sucks that we don't tree-combine COND_EXPRs.  Testcase:

int foo(int p)
{
  int q = p + 5;
  return q < p;
}
void bar(int p)
{
  int q = p + 5;
  if (q < p)
    link_error ();
}


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/26198] Unfolded comparison after cfg_cleanup
  2006-02-09 15:41 [Bug middle-end/26198] New: Unfolded comparison after cfg_cleanup rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-10-26  9:53 ` rguenth at gcc dot gnu dot org
@ 2007-03-05 17:07 ` rguenth at gcc dot gnu dot org
  2007-10-11 11:57 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-03-05 17:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2007-03-05 17:07 -------
Depends on (and is partly fixed by) PR30965.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |30965


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/26198] Unfolded comparison after cfg_cleanup
  2006-02-09 15:41 [Bug middle-end/26198] New: Unfolded comparison after cfg_cleanup rguenth at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-03-05 17:07 ` rguenth at gcc dot gnu dot org
@ 2007-10-11 11:57 ` rguenth at gcc dot gnu dot org
  2007-10-11 12:11 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-10-11 11:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2007-10-11 11:57 -------
The original issue seems to no longer trigger with the testcase, the missed
combining is fixed with a patch I have.


-- 

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|2006-02-09 15:43:14         |2007-10-11 11:57:13
               date|                            |


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/26198] Unfolded comparison after cfg_cleanup
  2006-02-09 15:41 [Bug middle-end/26198] New: Unfolded comparison after cfg_cleanup rguenth at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-10-11 11:57 ` rguenth at gcc dot gnu dot org
@ 2007-10-11 12:11 ` rguenth at gcc dot gnu dot org
  2007-10-12  8:42 ` rguenth at gcc dot gnu dot org
  2007-10-12  8:42 ` rguenth at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-10-11 12:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2007-10-11 12:10 -------
Also

  because in fold_binary where we handle this kind of stuff we have

              if (!offset0 || !offset1
                  || TREE_TYPE (offset0) == TREE_TYPE (offset1))
                {
  ...

is no longer true, we compare offsets in signed sizetype.


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/26198] Unfolded comparison after cfg_cleanup
  2006-02-09 15:41 [Bug middle-end/26198] New: Unfolded comparison after cfg_cleanup rguenth at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2007-10-12  8:42 ` rguenth at gcc dot gnu dot org
@ 2007-10-12  8:42 ` rguenth at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-10-12  8:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from rguenth at gcc dot gnu dot org  2007-10-12 08:42 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/26198] Unfolded comparison after cfg_cleanup
  2006-02-09 15:41 [Bug middle-end/26198] New: Unfolded comparison after cfg_cleanup rguenth at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2007-10-11 12:11 ` rguenth at gcc dot gnu dot org
@ 2007-10-12  8:42 ` rguenth at gcc dot gnu dot org
  2007-10-12  8:42 ` rguenth at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-10-12  8:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2007-10-12 08:42 -------
Subject: Bug 26198

Author: rguenth
Date: Fri Oct 12 08:42:13 2007
New Revision: 129256

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129256
Log:
2007-10-12  Richard Guenther  <rguenther@suse.de>

        PR middle-end/26198
        * tree-ssa-forwprop.c (can_propagate_from): Do not propagate from
        a rhs with side-effects or which is a load.
        (forward_propagate_into_cond): Also try combining both operands.

        * gcc.dg/tree-ssa/forwprop-3.c: New testcase.
        * gcc.c-torture/execute/20071011-1.c: Likewise.
        * gcc.dg/tree-ssa/ssa-pre-9.c: Adjust.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/20071011-1.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/forwprop-3.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-9.c
    trunk/gcc/tree-ssa-forwprop.c


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-10-12  8:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-09 15:41 [Bug middle-end/26198] New: Unfolded comparison after cfg_cleanup rguenth at gcc dot gnu dot org
2006-02-09 15:43 ` [Bug middle-end/26198] " pinskia at gcc dot gnu dot org
2006-06-19 20:10 ` rguenth at gcc dot gnu dot org
2006-10-26  9:53 ` rguenth at gcc dot gnu dot org
2007-03-05 17:07 ` rguenth at gcc dot gnu dot org
2007-10-11 11:57 ` rguenth at gcc dot gnu dot org
2007-10-11 12:11 ` rguenth at gcc dot gnu dot org
2007-10-12  8:42 ` rguenth at gcc dot gnu dot org
2007-10-12  8:42 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).