public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/46562] New: CCP currently needs iteration for &a[i]
@ 2010-11-19 15:45 rguenth at gcc dot gnu.org
  2010-11-19 15:50 ` [Bug tree-optimization/46562] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-11-19 15:45 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: CCP currently needs iteration for &a[i]
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: rguenth@gcc.gnu.org
        ReportedBy: rguenth@gcc.gnu.org


static int a[4];
int foo(void)
{
  int i = 1;
  int *p = &a[i];
  return *p;
}

compiled with the C++ FE (to yield an ARRAY_REF) shows that CCP needs
to iterate to figure out that p is a constant (and thus fold the read
from a[1]).


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

* [Bug tree-optimization/46562] CCP currently needs iteration for &a[i]
  2010-11-19 15:45 [Bug tree-optimization/46562] New: CCP currently needs iteration for &a[i] rguenth at gcc dot gnu.org
@ 2010-11-19 15:50 ` rguenth at gcc dot gnu.org
  2010-11-19 16:04 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-11-19 15:50 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2010.11.19 15:45:11
     Ever Confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-11-19 15:45:11 UTC ---
Mine.


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

* [Bug tree-optimization/46562] CCP currently needs iteration for &a[i]
  2010-11-19 15:45 [Bug tree-optimization/46562] New: CCP currently needs iteration for &a[i] rguenth at gcc dot gnu.org
  2010-11-19 15:50 ` [Bug tree-optimization/46562] " rguenth at gcc dot gnu.org
@ 2010-11-19 16:04 ` rguenth at gcc dot gnu.org
  2010-11-23 16:28 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-11-19 16:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-11-19 15:57:32 UTC ---
SCCVN also fails to recognize &a[i_1] as constant.

I'll add a get_addr_base_and_unit_offset variant with a callback to valueize
SSA names.  That should cover both.


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

* [Bug tree-optimization/46562] CCP currently needs iteration for &a[i]
  2010-11-19 15:45 [Bug tree-optimization/46562] New: CCP currently needs iteration for &a[i] rguenth at gcc dot gnu.org
  2010-11-19 15:50 ` [Bug tree-optimization/46562] " rguenth at gcc dot gnu.org
  2010-11-19 16:04 ` rguenth at gcc dot gnu.org
@ 2010-11-23 16:28 ` rguenth at gcc dot gnu.org
  2010-11-24 13:45 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-11-23 16:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-11-23 16:06:44 UTC ---
Created attachment 22498
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22498
wip patch

Work in progress patch.  Needs to transition functions elsewhere, hookize
fold_const_aggregate_ref and friends and also make VRP use
gimple_fold_stmt_to_constant.


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

* [Bug tree-optimization/46562] CCP currently needs iteration for &a[i]
  2010-11-19 15:45 [Bug tree-optimization/46562] New: CCP currently needs iteration for &a[i] rguenth at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2010-11-23 16:28 ` rguenth at gcc dot gnu.org
@ 2010-11-24 13:45 ` rguenth at gcc dot gnu.org
  2011-03-24 11:46 ` rguenth at gcc dot gnu.org
  2011-03-24 12:11 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-11-24 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #22498|0                           |1
        is obsolete|                            |

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-11-24 12:40:29 UTC ---
Created attachment 22508
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22508
updated patch

Patch also covering VRP.  Postponed for 4.7.


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

* [Bug tree-optimization/46562] CCP currently needs iteration for &a[i]
  2010-11-19 15:45 [Bug tree-optimization/46562] New: CCP currently needs iteration for &a[i] rguenth at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2010-11-24 13:45 ` rguenth at gcc dot gnu.org
@ 2011-03-24 11:46 ` rguenth at gcc dot gnu.org
  2011-03-24 12:11 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-24 11:46 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-24 11:23:34 UTC ---
Author: rguenth
Date: Thu Mar 24 11:23:29 2011
New Revision: 171386

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171386
Log:
2011-03-24  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/46562
    * tree.c (build_invariant_address): New function.
    * tree.h (build_invariant_address): Declare.
    * tree-dfa.c (get_addr_base_and_unit_offset): Wrap around
    a renamed function moved ...
    * tree-flow-inline.h (get_addr_base_and_unit_offset_1): ... here.
    Take valueization callback parameter.
    * tree-flow.h (gimple_fold_stmt_to_constant): Declare.
    * gimple-fold.h: New file.
    * tree-ssa-ccp.c (ccp_fold): Use gimple_fold_stmt_to_constant_1.
    (ccp_fold, fold_const_aggregate_ref,
    fold_ctor_reference, fold_nonarray_ctor_reference,
    fold_array_ctor_reference, fold_string_cst_ctor_reference,
    get_base_constructor): Move ...
    * gimple-fold.c: ... here.
    (gimple_fold_stmt_to_constant_1): New function
    split out from ccp_fold.  Take a valueization callback parameter.
    Valueize all operands.
    (gimple_fold_stmt_to_constant): New wrapper function.
    (fold_const_aggregate_ref_1): New function split out from
    fold_const_aggregate_ref.  Take a valueization callback parameter.
    (fold_const_aggregate_ref): Wrap fold_const_aggregate_ref_1.
    * tree-ssa-sccvn.c (simplify_binary_expression): Simplify
    invariant POINTER_PLUS_EXPRs to invariant form.
    (vn_valueize): New function.
    (try_to_simplify): Simplify by using gimple_fold_stmt_to_constant.
    * tree-vrp.c (vrp_valueize): New function.
    (vrp_visit_assignment_or_call): Use gimple_fold_stmt_to_constant
    to fold statements to constants.
    * tree-ssa-pre.c (eliminate): Properly guard propagation of
    function declarations.
    * Makefile.in (tree-ssa-sccvn.o, tree-vrp.o, gimple-fold.o,
    tree-ssa-ccp.o): Add gimple-fold.h dependencies.

    * c-c++-common/pr46562-2.c: New testcase.
    * c-c++-common/pr46562.c: Likewise.

Added:
    trunk/gcc/gimple-fold.h
    trunk/gcc/testsuite/c-c++-common/pr46562-2.c
    trunk/gcc/testsuite/c-c++-common/pr46562.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/gimple-fold.c
    trunk/gcc/ipa-split.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-dfa.c
    trunk/gcc/tree-flow-inline.h
    trunk/gcc/tree-flow.h
    trunk/gcc/tree-ssa-ccp.c
    trunk/gcc/tree-ssa-pre.c
    trunk/gcc/tree-ssa-sccvn.c
    trunk/gcc/tree-vrp.c
    trunk/gcc/tree.c
    trunk/gcc/tree.h


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

* [Bug tree-optimization/46562] CCP currently needs iteration for &a[i]
  2010-11-19 15:45 [Bug tree-optimization/46562] New: CCP currently needs iteration for &a[i] rguenth at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-03-24 11:46 ` rguenth at gcc dot gnu.org
@ 2011-03-24 12:11 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-24 12:11 UTC (permalink / raw)
  To: gcc-bugs


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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

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

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-24 11:59:40 UTC ---
Fixed.


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

end of thread, other threads:[~2011-03-24 11:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-19 15:45 [Bug tree-optimization/46562] New: CCP currently needs iteration for &a[i] rguenth at gcc dot gnu.org
2010-11-19 15:50 ` [Bug tree-optimization/46562] " rguenth at gcc dot gnu.org
2010-11-19 16:04 ` rguenth at gcc dot gnu.org
2010-11-23 16:28 ` rguenth at gcc dot gnu.org
2010-11-24 13:45 ` rguenth at gcc dot gnu.org
2011-03-24 11:46 ` rguenth at gcc dot gnu.org
2011-03-24 12:11 ` rguenth at gcc dot gnu.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).