* [Bug tree-optimization/24689] store_ccp is missing an opportunity because of call clobber/alias load?
2005-11-06 2:26 [Bug tree-optimization/24689] New: store_ccp is missing an opportunity!? kazu at gcc dot gnu dot org
@ 2005-11-06 4:34 ` pinskia at gcc dot gnu dot org
2005-11-06 4:47 ` pinskia at gcc dot gnu dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-06 4:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2005-11-06 04:34 -------
Looks like another one of the call clobbered bugs:
Variable: buf, UID 1612, char[1], is an alias tag, is addressable, call
clobbered, default def: buf_2
Though that should not matter.
Here is a testcase where call clobberness is correct but it should not matter
as there is no way for the change to happen:
extern void bar (unsigned int);
extern void bar1 (const char **);
int
foo (void)
{
char buf[1] = { 3 };
const char *p = buf;
const char **q = &p;
unsigned int ch;
switch (**q)
{
case 1: ch = 5; break;
default: ch = 0; break;
}
bar (ch);
bar1 (q);
return ch;
}
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |alias
Last reconfirmed|0000-00-00 00:00:00 |2005-11-06 04:34:23
date| |
Summary|store_ccp is missing an |store_ccp is missing an
|opportunity!? |opportunity because of call
| |clobber/alias load?
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24689
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/24689] store_ccp is missing an opportunity because of call clobber/alias load?
2005-11-06 2:26 [Bug tree-optimization/24689] New: store_ccp is missing an opportunity!? kazu at gcc dot gnu dot org
2005-11-06 4:34 ` [Bug tree-optimization/24689] store_ccp is missing an opportunity because of call clobber/alias load? pinskia at gcc dot gnu dot org
@ 2005-11-06 4:47 ` pinskia at gcc dot gnu dot org
2005-11-06 4:50 ` [Bug tree-optimization/24689] store_ccp does nothing for array references pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-06 4:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2005-11-06 04:47 -------
Note switch statements here have nothing to do with the real issue:
extern void bar (unsigned int);
extern void bar1 (const char **);
int
foo (void)
{
char buf[1] = { 3 };
const char *p = buf;
const char **q = &p;
unsigned int ch;
if(**q)
{
ch = 1;
}
else ch =2;
bar (ch);
bar1 (q);
return ch;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24689
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/24689] store_ccp does nothing for array references
2005-11-06 2:26 [Bug tree-optimization/24689] New: store_ccp is missing an opportunity!? kazu at gcc dot gnu dot org
2005-11-06 4:34 ` [Bug tree-optimization/24689] store_ccp is missing an opportunity because of call clobber/alias load? pinskia at gcc dot gnu dot org
2005-11-06 4:47 ` pinskia at gcc dot gnu dot org
@ 2005-11-06 4:50 ` pinskia at gcc dot gnu dot org
2005-11-06 4:53 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-06 4:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2005-11-06 04:50 -------
(In reply to comment #0)
> This function should be optimized to "return 0;", but it isn't.
> Interestingly, if you change "#if 1" to "#if 0", you are going to get
> this optimized.
Not really because SRA works then, using -fno-tree-sra will show the same
issue.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|store_ccp is missing an |store_ccp does nothing for
|opportunity because of call |array references
|clobber/alias load? |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24689
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/24689] store_ccp does nothing for array references
2005-11-06 2:26 [Bug tree-optimization/24689] New: store_ccp is missing an opportunity!? kazu at gcc dot gnu dot org
` (2 preceding siblings ...)
2005-11-06 4:50 ` [Bug tree-optimization/24689] store_ccp does nothing for array references pinskia at gcc dot gnu dot org
@ 2005-11-06 4:53 ` pinskia at gcc dot gnu dot org
2006-01-15 21:35 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-06 4:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2005-11-06 04:52 -------
Here is another testcase:
extern void bar (unsigned int);
extern void bar1 (const char **);
char buf[1];
int
foo (void)
{
const char *p = buf;
const char **q = &p;
buf[0] = 3;
unsigned int ch;
if(**q)
{
ch = 1;
}
else ch =2;
return ch;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24689
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/24689] store_ccp does nothing for array references
2005-11-06 2:26 [Bug tree-optimization/24689] New: store_ccp is missing an opportunity!? kazu at gcc dot gnu dot org
` (3 preceding siblings ...)
2005-11-06 4:53 ` pinskia at gcc dot gnu dot org
@ 2006-01-15 21:35 ` pinskia at gcc dot gnu dot org
2006-01-16 6:02 ` [Bug tree-optimization/24689] operand_equal_p does not return true for some equivalent ARRAY_REF pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-15 21:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pinskia at gcc dot gnu dot org 2006-01-15 21:35 -------
I am going to look into this soon but I don't think it is an aliasing issue as
shown by:
# SFT.0_6 = V_MUST_DEF <SFT.0_5>;
buf[0] = 3;
# VUSE <SFT.0_6>;
D.1523_8 = buf[0];
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24689
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/24689] operand_equal_p does not return true for some equivalent ARRAY_REF
2005-11-06 2:26 [Bug tree-optimization/24689] New: store_ccp is missing an opportunity!? kazu at gcc dot gnu dot org
` (4 preceding siblings ...)
2006-01-15 21:35 ` pinskia at gcc dot gnu dot org
@ 2006-01-16 6:02 ` pinskia at gcc dot gnu dot org
2007-04-11 10:13 ` rguenth at gcc dot gnu dot org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-16 6:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2006-01-16 06:02 -------
The problem here is that operand_equal_p returns false for these two trees:
<array_ref 0x41da4b94
type <integer_type 0x41d1b180 char sizes-gimplified public QI
size <integer_cst 0x41d0a320 constant invariant 8>
unit size <integer_cst 0x41d0a340 constant invariant 1>
align 8 symtab 0 alias set -1 precision 8 min <integer_cst 0x41d0a3a0
-128> max <integer_cst 0x41d0a420 127>
pointer_to_this <pointer_type 0x41d23120>>
arg 0 <var_decl 0x41da2540 buf
type <array_type 0x41da24e0 type <integer_type 0x41d1b180 char>
QI size <integer_cst 0x41d0a320 8> unit size <integer_cst
0x41d0a340 1>
align 8 symtab 0 alias set -1 domain <integer_type 0x41da2480>>
addressable used public static common QI file t.c line 4 size
<integer_cst 0x41d0a320 8> unit size <integer_cst 0x41d0a340 1>
align 8
chain <function_decl 0x41da3680 foo type <function_type 0x41d236c0>
public static SI file t.c line 7 initial <block 0x41da4bfc> result
<result_decl 0x41d12268 D.1518>
(mem:SI (symbol_ref:SI ("foo") [flags 0x103] <function_decl
0x41da3680 foo>) [0 S4 A8])
saved-insns 0x41d85c00>>
arg 1 <integer_cst 0x41d0ab40 type <integer_type 0x41d1b2a0 int> constant
invariant 0>>
and
<array_ref 0x41dab6b4
type <integer_type 0x41d23300 char readonly sizes-gimplified public QI
size <integer_cst 0x41d0a320 constant invariant 8>
unit size <integer_cst 0x41d0a340 constant invariant 1>
align 8 symtab 0 alias set -1 precision 8 min <integer_cst 0x41d0a3a0
-128> max <integer_cst 0x41d0a420 127>
pointer_to_this <pointer_type 0x41d23360>>
arg 0 <var_decl 0x41da2540 buf
type <array_type 0x41da24e0 type <integer_type 0x41d1b180 char>
QI size <integer_cst 0x41d0a320 8> unit size <integer_cst
0x41d0a340 1>
align 8 symtab 0 alias set -1 domain <integer_type 0x41da2480>>
addressable used public static common QI file t.c line 4 size
<integer_cst 0x41d0a320 8> unit size <integer_cst 0x41d0a340 1>
align 8
chain <function_decl 0x41da3680 foo type <function_type 0x41d236c0>
public static SI file t.c line 7 initial <block 0x41da4bfc> result
<result_decl 0x41d12268 D.1518>
(mem:SI (symbol_ref:SI ("foo") [flags 0x103] <function_decl
0x41da3680 foo>) [0 S4 A8])
saved-insns 0x41d85c00>>
arg 1 <integer_cst 0x41d76600 type <integer_type 0x41da2480> constant
invariant 0>
arg 2 <integer_cst 0x41d0a2a0 type <integer_type 0x41d1b000 long unsigned
int> constant invariant 0> arg 3 <integer_cst 0x41d0a340 1>>
Even they point to the same spot, it does not work as the two array reference
have different arg2/arg3.
So Store_CCP is doing the correct thing, just the function it depends on is
not.
And the reason for this problem is because when changing **q into buf[0], it
does not fill out those two arguments to the tree.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|alias |
Summary|store_ccp does nothing for |operand_equal_p does not
|array references |return true for some
| |equivalent ARRAY_REF
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24689
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/24689] operand_equal_p does not return true for some equivalent ARRAY_REF
2005-11-06 2:26 [Bug tree-optimization/24689] New: store_ccp is missing an opportunity!? kazu at gcc dot gnu dot org
` (5 preceding siblings ...)
2006-01-16 6:02 ` [Bug tree-optimization/24689] operand_equal_p does not return true for some equivalent ARRAY_REF pinskia at gcc dot gnu dot org
@ 2007-04-11 10:13 ` rguenth at gcc dot gnu dot org
2007-04-11 12:03 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-11 10:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from rguenth at gcc dot gnu dot org 2007-04-11 11:13 -------
I have a patch.
--
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-10-30 02:29:43 |2007-04-11 11:13:33
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24689
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/24689] operand_equal_p does not return true for some equivalent ARRAY_REF
2005-11-06 2:26 [Bug tree-optimization/24689] New: store_ccp is missing an opportunity!? kazu at gcc dot gnu dot org
` (6 preceding siblings ...)
2007-04-11 10:13 ` rguenth at gcc dot gnu dot org
@ 2007-04-11 12:03 ` pinskia at gcc dot gnu dot org
2007-04-11 13:51 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-11 12:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pinskia at gcc dot gnu dot org 2007-04-11 13:03 -------
I should make a note here that if operand_equal_p returns true, iterative hash
has to be the same also.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24689
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/24689] operand_equal_p does not return true for some equivalent ARRAY_REF
2005-11-06 2:26 [Bug tree-optimization/24689] New: store_ccp is missing an opportunity!? kazu at gcc dot gnu dot org
` (7 preceding siblings ...)
2007-04-11 12:03 ` pinskia at gcc dot gnu dot org
@ 2007-04-11 13:51 ` rguenth at gcc dot gnu dot org
2007-04-12 9:16 ` rguenth at gcc dot gnu dot org
2007-04-12 9:28 ` rguenth at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-11 13:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from rguenth at gcc dot gnu dot org 2007-04-11 14:51 -------
Luckily iterative hash hashes low/high of integer consts only, not the type.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24689
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/24689] operand_equal_p does not return true for some equivalent ARRAY_REF
2005-11-06 2:26 [Bug tree-optimization/24689] New: store_ccp is missing an opportunity!? kazu at gcc dot gnu dot org
` (8 preceding siblings ...)
2007-04-11 13:51 ` rguenth at gcc dot gnu dot org
@ 2007-04-12 9:16 ` rguenth at gcc dot gnu dot org
2007-04-12 9:28 ` rguenth at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-12 9:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from rguenth at gcc dot gnu dot org 2007-04-12 10:16 -------
Subject: Bug 24689
Author: rguenth
Date: Thu Apr 12 10:15:53 2007
New Revision: 123736
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123736
Log:
2007-04-12 Richard Guenther <rguenther@suse.de>
PR tree-optimization/24689
PR tree-optimization/31307
* fold-const.c (operand_equal_p): Compare INTEGER_CST array
indices by value.
* gimplify.c (canonicalize_addr_expr): To be consistent with
gimplify_compound_lval only set operands two and three of
ARRAY_REFs if they are not gimple_min_invariant. This makes
it never at this place.
* tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise.
* g++.dg/tree-ssa/pr31307.C: New testcase.
* gcc.dg/tree-ssa/pr24689.c: Likewise.
Added:
trunk/gcc/testsuite/g++.dg/tree-ssa/pr31307.C
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr24689.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fold-const.c
trunk/gcc/gimplify.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-ccp.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24689
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/24689] operand_equal_p does not return true for some equivalent ARRAY_REF
2005-11-06 2:26 [Bug tree-optimization/24689] New: store_ccp is missing an opportunity!? kazu at gcc dot gnu dot org
` (9 preceding siblings ...)
2007-04-12 9:16 ` rguenth at gcc dot gnu dot org
@ 2007-04-12 9:28 ` rguenth at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-12 9:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from rguenth at gcc dot gnu dot org 2007-04-12 10:28 -------
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=24689
^ permalink raw reply [flat|nested] 12+ messages in thread