public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/30965]  New: Fails to tree-combine conditions in COND_EXPRs
@ 2007-02-26 10:32 rguenth at gcc dot gnu dot org
  2007-03-02 20:04 ` [Bug tree-optimization/30965] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-02-26 10:32 UTC (permalink / raw)
  To: gcc-bugs

(split from PR19431)

#include <tr1/functional>
#include <algorithm>
extern void assign( long* variable, long v )
{
        std::transform( variable, variable + 1, variable,
                std::tr1::bind( std::plus< long >(), 0L, v ) );
}
extern void assign( long& variable, long v )
{
        std::transform( &variable, &variable + 1, &variable,
                std::tr1::bind( std::plus< long >(), 0L, v ) );
}

at -O3 gcc 4.2 produces:

assign(long&, long):
        movq    -40(%rsp), %rax
        movq    %rsi, -24(%rsp)
        movq    $0, -32(%rsp)
        movq    $0, -64(%rsp)
        movq    %rsi, -56(%rsp)
        movq    %rsi, (%rdi)
        movq    %rax, -72(%rsp)
        ret

assign(long*, long):
        movq    %rsi, (%rdi)
        ret

The problem is:

We start with

  D.59982_3 = variable_2(D) + 4B;
  __unary_op = __unary_op.65;
  goto <bb 4> (<L1>);

<L0>:;
  D.61146_10 = __unary_op._M_arg1;
  D.61147_11 = __unary_op._M_arg2;
  D.61093_12 = D.61146_10 + D.61147_11;
  *variable_13 = D.61093_12;
  variable_14 = variable_7 + 4B;
  variable_15 = variable_13 + 4B;

  # variable_7 = PHI <variable_2(D)(2), variable_14(3)>
  # variable_13 = PHI <variable_2(D)(2), variable_15(3)>
<L1>:;
  if (D.59982_3 != variable_7) goto <L0>; else goto <L2>;

and loop header copying and DOM make it optimizable:

  D.59982_3 = variable_2(D) + 4B;
  __unary_op.65._M_arg2 = v_1(D);
  __unary_op.65._M_arg1 = 0;
  __unary_op = __unary_op.65;
  __unary_op$_M_arg2_54 = __unary_op._M_arg2;
  __unary_op$_M_arg1_53 = __unary_op._M_arg1;
  if (variable_2(D) != D.59982_3) goto <L7>; else goto <L2>;

<L2>:;
  return;

  # variable_49 = PHI <variable_2(D)(2)>
  # variable_27 = PHI <variable_2(D)(2)>
<L7>:;
  __unary_op$_M_arg1_25 = __unary_op$_M_arg1_53;
  __unary_op$_M_arg2_17 = __unary_op$_M_arg2_54;
  D.61093_18 = __unary_op$_M_arg1_53 + __unary_op$_M_arg2_54;
  *variable_49 = D.61093_18;
  variable_20 = variable_27 + 4B;
  variable_21 = variable_49 + 4B;
  goto <bb 3> (<L2>);

so a tweaked forwprop fixes it at least before PRE.  But dunno if we want
to do tree combining on conditions here.  The code is optimized at
RTL expansion time.


-- 
           Summary: Fails to tree-combine conditions in COND_EXPRs
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, TREE
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        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=30965


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
@ 2007-03-02 20:04 ` pinskia at gcc dot gnu dot org
  2007-03-16 19:38 ` jv244 at cam dot ac dot uk
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-02 20:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-03-02 20:04 -------
*** Bug 31029 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jv244 at cam dot ac dot uk


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


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
  2007-03-02 20:04 ` [Bug tree-optimization/30965] " pinskia at gcc dot gnu dot org
@ 2007-03-16 19:38 ` jv244 at cam dot ac dot uk
  2007-04-14 10:01 ` jv244 at cam dot ac dot uk
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jv244 at cam dot ac dot uk @ 2007-03-16 19:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jv244 at cam dot ac dot uk  2007-03-16 19:38 -------
just to keep track, patch here:

http://gcc.gnu.org/ml/gcc-patches/2007-03/msg00129.html


-- 


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


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
  2007-03-02 20:04 ` [Bug tree-optimization/30965] " pinskia at gcc dot gnu dot org
  2007-03-16 19:38 ` jv244 at cam dot ac dot uk
@ 2007-04-14 10:01 ` jv244 at cam dot ac dot uk
  2007-04-14 11:57 ` rguenth at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jv244 at cam dot ac dot uk @ 2007-04-14 10:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jv244 at cam dot ac dot uk  2007-04-14 11:00 -------

> http://gcc.gnu.org/ml/gcc-patches/2007-03/msg00129.html

should this one be pinged ?


-- 


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


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-04-14 10:01 ` jv244 at cam dot ac dot uk
@ 2007-04-14 11:57 ` rguenth at gcc dot gnu dot org
  2007-04-27 13:44 ` rguenth at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-14 11:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2007-04-14 12:57 -------
I need to update it.


-- 


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


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-04-14 11:57 ` rguenth at gcc dot gnu dot org
@ 2007-04-27 13:44 ` rguenth at gcc dot gnu dot org
  2007-04-27 13:56 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-27 13:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2007-04-27 14:44 -------
Subject: Bug 30965

Author: rguenth
Date: Fri Apr 27 14:43:42 2007
New Revision: 124217

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

        PR tree-optimization/30965
        PR tree-optimization/30978
        * Makefile.in (tree-ssa-forwprop.o): Depend on $(FLAGS_H).
        * tree-ssa-forwprop.c (forward_propagate_into_cond_1): Remove.
        (find_equivalent_equality_comparison): Likewise.
        (simplify_cond): Likewise.
        (get_prop_source_stmt): New helper.
        (get_prop_dest_stmt): Likewise.
        (can_propagate_from): Likewise.
        (remove_prop_source_from_use): Likewise.
        (combine_cond_expr_cond): Likewise.
        (forward_propagate_comparison): New function.
        (forward_propagate_into_cond): Rewrite to use fold for
        tree combining.
        (tree_ssa_forward_propagate_single_use_vars): Call
        forward_propagate_comparison to propagate comparisons.

        * gcc.dg/tree-ssa/pr30978.c: New testcase.
        * gcc.dg/tree-ssa/bool-3.c: Remove XFAIL, explain why.
        * gcc.dg/tree-ssa/ssa-fre-4.c: Use char instead of bool
        * gcc.dg/strict-overflow-5.c: Adjust tree dump scanning.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr30978.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/strict-overflow-5.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/bool-3.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-4.c
    trunk/gcc/tree-ssa-forwprop.c


-- 


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


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-04-27 13:44 ` rguenth at gcc dot gnu dot org
@ 2007-04-27 13:56 ` rguenth at gcc dot gnu dot org
  2007-04-27 13:56 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-27 13:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2007-04-27 14:56 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2007-04-27 13:56 ` rguenth at gcc dot gnu dot org
@ 2007-04-27 13:56 ` rguenth at gcc dot gnu dot org
  2007-07-05 17:35 ` pluto at agmk dot net
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-27 13:56 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.0


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


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2007-04-27 13:56 ` rguenth at gcc dot gnu dot org
@ 2007-07-05 17:35 ` pluto at agmk dot net
  2007-07-05 17:51 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pluto at agmk dot net @ 2007-07-05 17:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pluto at agmk dot net  2007-07-05 17:35 -------
(In reply to comment #6)
> Fixed.

Richard, there's a recent regresion in 4.3/r126266:

_ZSt9transformIPlS0_NSt3tr15_BindIFSt4plusIlEllEEEET0_T_S8_S7_T1_:
        cmpq    %rsi, %rdi
        je      .L2
        addq    $8, %rdi
        movq    %rdx, %r9
        movq    %rdi, %r8
        .p2align 4,,10
        .p2align 3
.L3:
        movq    8(%rcx), %rax
        addq    16(%rcx), %rax
        addq    $8, %r8
        movq    %rax, (%r9)
        leaq    -8(%r8), %rax
        addq    $8, %r9
        cmpq    %rax, %rsi
        jne     .L3
        subq    %rdi, %rsi
        shrq    $3, %rsi
        leaq    8(%rdx,%rsi,8), %rdx
.L2:
        movq    %rdx, %rax
        ret

_Z6assignRll:
        subq    $40, %rsp
        movq    %rdi, %rdx
        movq    %rsi, 8(%rsp)
        leaq    8(%rdi), %rsi
        movq    %rsp, %rcx
        movq    $0, 16(%rsp)
        call   
_ZSt9transformIPlS0_NSt3tr15_BindIFSt4plusIlEllEEEET0_T_S8_S7_T1_
        addq    $40, %rsp
        ret

_Z6assignPll:
        subq    $40, %rsp
        movq    %rdi, %rdx
        movq    %rsi, 8(%rsp)
        leaq    8(%rdi), %rsi
        movq    %rsp, %rcx
        movq    $0, 16(%rsp)
        call   
_ZSt9transformIPlS0_NSt3tr15_BindIFSt4plusIlEllEEEET0_T_S8_S7_T1_
        addq    $40, %rsp
        ret


-- 


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


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2007-07-05 17:35 ` pluto at agmk dot net
@ 2007-07-05 17:51 ` rguenth at gcc dot gnu dot org
  2007-07-05 18:22 ` pluto at agmk dot net
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-07-05 17:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from rguenth at gcc dot gnu dot org  2007-07-05 17:51 -------
This is related to the gimplifier verifying call expression types to disable
inlining.  In this case the argument type list says we need struct _Bind, but
the actual argument is struct _Bind*.  Oh well.


-- 


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


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2007-07-05 17:51 ` rguenth at gcc dot gnu dot org
@ 2007-07-05 18:22 ` pluto at agmk dot net
  2007-07-05 18:29 ` rguenther at suse dot de
  2007-07-05 20:25 ` rguenth at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pluto at agmk dot net @ 2007-07-05 18:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pluto at agmk dot net  2007-07-05 18:21 -------
(In reply to comment #8)
> This is related to the gimplifier verifying call expression types to disable
> inlining.  In this case the argument type list says we need struct _Bind, but
> the actual argument is struct _Bind*.  Oh well.

should i fill a separated PR for this issue?


-- 


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


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2007-07-05 18:22 ` pluto at agmk dot net
@ 2007-07-05 18:29 ` rguenther at suse dot de
  2007-07-05 20:25 ` rguenth at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenther at suse dot de @ 2007-07-05 18:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from rguenther at suse dot de  2007-07-05 18:29 -------
Subject: Re:  Fails to tree-combine conditions
 in COND_EXPRs

On Thu, 5 Jul 2007, pluto at agmk dot net wrote:

> 
> 
> ------- Comment #9 from pluto at agmk dot net  2007-07-05 18:21 -------
> (In reply to comment #8)
> > This is related to the gimplifier verifying call expression types to disable
> > inlining.  In this case the argument type list says we need struct _Bind, but
> > the actual argument is struct _Bind*.  Oh well.
> 
> should i fill a separated PR for this issue?

Yes, that would be nice.

richard.


-- 


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


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

* [Bug tree-optimization/30965] Fails to tree-combine conditions in COND_EXPRs
  2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2007-07-05 18:29 ` rguenther at suse dot de
@ 2007-07-05 20:25 ` rguenth at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-07-05 20:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from rguenth at gcc dot gnu dot org  2007-07-05 20:25 -------
I have a fix.


-- 


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


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

end of thread, other threads:[~2007-07-05 20:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-26 10:32 [Bug tree-optimization/30965] New: Fails to tree-combine conditions in COND_EXPRs rguenth at gcc dot gnu dot org
2007-03-02 20:04 ` [Bug tree-optimization/30965] " pinskia at gcc dot gnu dot org
2007-03-16 19:38 ` jv244 at cam dot ac dot uk
2007-04-14 10:01 ` jv244 at cam dot ac dot uk
2007-04-14 11:57 ` rguenth at gcc dot gnu dot org
2007-04-27 13:44 ` rguenth at gcc dot gnu dot org
2007-04-27 13:56 ` rguenth at gcc dot gnu dot org
2007-04-27 13:56 ` rguenth at gcc dot gnu dot org
2007-07-05 17:35 ` pluto at agmk dot net
2007-07-05 17:51 ` rguenth at gcc dot gnu dot org
2007-07-05 18:22 ` pluto at agmk dot net
2007-07-05 18:29 ` rguenther at suse dot de
2007-07-05 20:25 ` 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).