This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/14841] [tree-ssa] const_array[CST] is not folded
- From: "steven at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Aug 2004 00:04:28 -0000
- Subject: [Bug tree-optimization/14841] [tree-ssa] const_array[CST] is not folded
- References: <20040403234930.14841.kazu@cs.umass.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From steven at gcc dot gnu dot org 2004-08-13 00:04 -------
Given your test case,
(gdb) set args -O2 t.c
(gdb) b fold if (current_function_decl != (tree*)0)
Breakpoint 5 at 0x658717: file ../../mainline/gcc/fold-const.c, line 6018.
(gdb) run
Starting program: /space/stevenb/build/gcc/cc1 -O2 t.c
Breakpoint 3 at 0x2a9569d9c0
Breakpoint 4 at 0x2a9569c750
foo
Breakpoint 5, fold (expr=0x2a95905f80) at ../../mainline/gcc/fold-const.c:6018
6018 const tree t = expr;
(gdb) p debug_generic_expr (expr)
banana<D1464>[2]
$2 = void
(gdb) p debug_tree(expr)
<array_ref 0x2a95905f80
type <integer_type 0x2a955978c0 int SI
size <integer_cst 0x2a95595780 constant invariant 32>
unit size <integer_cst 0x2a955958d0 constant invariant 4>
align 32 symtab 0 alias set -1 precision 32 min <integer_cst
0x2a95595870 -2147483648> max <integer_cst 0x2a955958a0 2147483647>
pointer_to_this <pointer_type 0x2a955a8540>>
readonly
arg 0 <var_decl 0x2a95901ee0 banana
type <array_type 0x2a95901e00 type <integer_type 0x2a9562ec40 int>
BLK
size <integer_cst 0x2a95595de0 constant invariant 128>
unit size <integer_cst 0x2a9559f4b0 constant invariant 16>
align 32 symtab 0 alias set -1 domain <integer_type 0x2a95629a80>>
readonly used static BLK file t.c line 1 size <integer_cst
0x2a95595de0 128> unit size <integer_cst 0x2a9559f4b0 16>
align 32 initial <constructor 0x2a9562c080>>
arg 1 <integer_cst 0x2a95913f30 type <integer_type 0x2a955978c0 int>
constant invariant 2>>
$3 = void
(gdb) p debug_tree ((tree *)0x2a9562c080)
<constructor 0x2a9562c080
type <array_type 0x2a95901e00
type <integer_type 0x2a9562ec40 int readonly SI
size <integer_cst 0x2a95595780 constant invariant 32>
unit size <integer_cst 0x2a955958d0 constant invariant 4>
align 32 symtab 0 alias set -1 precision 32 min <integer_cst
0x2a95595870 -2147483648> max <integer_cst 0x2a955958a0 2147483647>
pointer_to_this <pointer_type 0x2a9562ed20>>
BLK
size <integer_cst 0x2a95595de0 constant invariant 128>
unit size <integer_cst 0x2a9559f4b0 constant invariant 16>
align 32 symtab 0 alias set -1
domain <integer_type 0x2a95629a80 type <integer_type 0x2a955a6700 long
unsigned int>
DI
size <integer_cst 0x2a95595900 constant invariant 64>
unit size <integer_cst 0x2a95595a50 constant invariant 8>
align 64 symtab 0 alias set -1 precision 64 min <integer_cst
0x2a9559f5d0 0> max <integer_cst 0x2a95628000 3>>>
constant invariant static
arg 0 <tree_list 0x2a959139f0
purpose <integer_cst 0x2a959139c0 constant invariant 0>
value <integer_cst 0x2a95913990 constant invariant 0>
chain <tree_list 0x2a95913a80
purpose <integer_cst 0x2a95913a50 constant invariant 1>
value <integer_cst 0x2a95913a20 constant invariant 1>
chain <tree_list 0x2a95913b10
purpose <integer_cst 0x2a95913ae0 constant invariant 2>
value <integer_cst 0x2a95913ab0 constant invariant 2>
chain <tree_list 0x2a95913bd0
purpose <integer_cst 0x2a95913ba0 constant invariant 3>
value <integer_cst 0x2a95913b70 constant invariant 3>>>>>>
$4 = void
(gdb)
So somebody should just teach fold-const to fold ARRAY_REFs to
readonly memory.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14841