public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/19807] New: fold does not fold &a[4]-1
@ 2005-02-07 23:13 rguenth at gcc dot gnu dot org
2005-02-07 23:15 ` [Bug middle-end/19807] " rguenth at gcc dot gnu dot org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-02-07 23:13 UTC (permalink / raw)
To: gcc-bugs
PR19639 is pessimized by (?)
extern void link_error(void);
int main(void)
{
int a[4];
if (&a[2]-1 != &a[1])
link_error();
return 0;
}
where for C++ (!!) we do not fold the addition of ADDR_EXPR (ARRAY_REF (..))
and INTEGER_CST into the ARRAY_REF offset. For C the frontend avoids
passing ARRAY_REFs to fold.
--
Summary: fold does not fold &a[4]-1
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rguenth at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
OtherBugsDependingO 19639
nThis:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19807
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/19807] fold does not fold &a[4]-1
2005-02-07 23:13 [Bug middle-end/19807] New: fold does not fold &a[4]-1 rguenth at gcc dot gnu dot org
@ 2005-02-07 23:15 ` rguenth at gcc dot gnu dot org
2005-02-07 23:16 ` rguenth at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-02-07 23:15 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO|19639 |
nThis| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19807
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/19807] fold does not fold &a[4]-1
2005-02-07 23:13 [Bug middle-end/19807] New: fold does not fold &a[4]-1 rguenth at gcc dot gnu dot org
2005-02-07 23:15 ` [Bug middle-end/19807] " rguenth at gcc dot gnu dot org
@ 2005-02-07 23:16 ` rguenth at gcc dot gnu dot org
2005-02-08 2:34 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-02-07 23:16 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |19639
nThis| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19807
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/19807] fold does not fold &a[4]-1
2005-02-07 23:13 [Bug middle-end/19807] New: fold does not fold &a[4]-1 rguenth at gcc dot gnu dot org
2005-02-07 23:15 ` [Bug middle-end/19807] " rguenth at gcc dot gnu dot org
2005-02-07 23:16 ` rguenth at gcc dot gnu dot org
@ 2005-02-08 2:34 ` pinskia at gcc dot gnu dot org
2005-02-09 17:40 ` rguenth at gcc dot gnu dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-08 2:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-02-07 19:30 -------
Confirmed.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-02-07 19:30:41
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19807
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/19807] fold does not fold &a[4]-1
2005-02-07 23:13 [Bug middle-end/19807] New: fold does not fold &a[4]-1 rguenth at gcc dot gnu dot org
` (2 preceding siblings ...)
2005-02-08 2:34 ` pinskia at gcc dot gnu dot org
@ 2005-02-09 17:40 ` rguenth at gcc dot gnu dot org
2005-04-23 21:37 ` rguenth at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-02-09 17:40 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-02-09 11:15 -------
Another testcase is the following:
xtern void link_error(void);
void foo(int i)
{
int a[4];
if ((char*)&a[1] + 4*i + 4 != (char*)&a[i+2])
link_error();
if (&a[1] + i + 1 != &a[i+2])
link_error();
}
which I have a patch for that works for C++ by extending the existing
try_move_mult_to_index and trying to avoid inserting (unsinged) casts
there.
Unfortunately, for C (whose initial trees do not contain ARRAY_REF exprs),
the frontend already inserts casts to unsigned (.03.generic):
foo (i)
{
charD.1 * a.0D.1129;
intD.0 D.1130;
charD.1 * D.1131;
charD.1 * D.1132;
charD.1 * D.1133;
unsigned intD.3 i.1D.1134;
unsigned intD.3 D.1135;
intD.0 * D.1136;
intD.0 * D.1137;
intD.0 * D.1138;
charD.1 * D.1139;
intD.0 aD.1128[4];
a.0D.1129 = (charD.1 *) &aD.1128;
D.1130 = iD.1125 * 4;
D.1131 = (charD.1 *) D.1130;
D.1132 = a.0D.1129 + D.1131;
D.1133 = D.1132 + 8B;
i.1D.1134 = (unsigned intD.3) iD.1125;
D.1135 = i.1D.1134 * 4;
D.1136 = (intD.0 *) D.1135;
D.1137 = &aD.1128 + D.1136;
D.1138 = D.1137 + 8B;
D.1139 = (charD.1 *) D.1138;
if (D.1133 != D.1139)
{
link_error ();
}
else
{
}
if (0)
{
link_error ();
}
else
{
}
}
which maybe even wrong, if not hindering optimizations at least.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2005-02-07 19:30:41 |2005-02-09 11:15:29
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19807
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/19807] fold does not fold &a[4]-1
2005-02-07 23:13 [Bug middle-end/19807] New: fold does not fold &a[4]-1 rguenth at gcc dot gnu dot org
` (3 preceding siblings ...)
2005-02-09 17:40 ` rguenth at gcc dot gnu dot org
@ 2005-04-23 21:37 ` rguenth at gcc dot gnu dot org
2005-04-25 14:49 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-04-23 21:37 UTC (permalink / raw)
To: gcc-bugs
--
Bug 19807 depends on bug 21082, which changed state.
Bug 21082 Summary: &a[b] - &a[c] is not folded to b - c
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21082
What |Old Value |New Value
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19807
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/19807] fold does not fold &a[4]-1
2005-02-07 23:13 [Bug middle-end/19807] New: fold does not fold &a[4]-1 rguenth at gcc dot gnu dot org
` (4 preceding siblings ...)
2005-04-23 21:37 ` rguenth at gcc dot gnu dot org
@ 2005-04-25 14:49 ` pinskia at gcc dot gnu dot org
2005-05-11 8:15 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-25 14:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-25 14:49 -------
Patch posted: <http://gcc.gnu.org/ml/gcc-patches/2005-04/msg02592.html>.
--
What |Removed |Added
----------------------------------------------------------------------------
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2005-
| |04/msg02592.html
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19807
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/19807] fold does not fold &a[4]-1
2005-02-07 23:13 [Bug middle-end/19807] New: fold does not fold &a[4]-1 rguenth at gcc dot gnu dot org
` (5 preceding siblings ...)
2005-04-25 14:49 ` pinskia at gcc dot gnu dot org
@ 2005-05-11 8:15 ` cvs-commit at gcc dot gnu dot org
2005-05-11 9:07 ` rguenth at gcc dot gnu dot org
2005-05-11 9:08 ` rguenth at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-05-11 8:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-05-11 08:15 -------
Subject: Bug 19807
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: rguenth@gcc.gnu.org 2005-05-11 08:14:45
Modified files:
gcc : ChangeLog fold-const.c tree-ssa-propagate.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/tree-ssa: pr19807.C
Log message:
2005-05-11 Richard Guenther <rguenth@gcc.gnu.org>
PR middle-end/19807
PR tree-optimization/19639
* fold-const.c (try_move_mult_to_index): Handle INTEGER_CST
and generic summands for char* as s * delta, too, folding &a[i]
CODE x to &a[i CODE x/s]. Use tree_int_cst_equal
for comparison of steps. Convert types for index addition.
(fold_binary): Adjust the callers to always dispatch to
try_move_mult_to_index.
* tree-ssa-propagate.c (set_rhs): Avoid setting rhs to
expr with non-gimple ARRAY_REF offset.
* g++.dg/tree-ssa/pr19807.C: New testcase.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8725&r2=2.8726
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.576&r2=1.577
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-propagate.c.diff?cvsroot=gcc&r1=2.18&r2=2.19
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5463&r2=1.5464
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/tree-ssa/pr19807.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19807
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/19807] fold does not fold &a[4]-1
2005-02-07 23:13 [Bug middle-end/19807] New: fold does not fold &a[4]-1 rguenth at gcc dot gnu dot org
` (6 preceding siblings ...)
2005-05-11 8:15 ` cvs-commit at gcc dot gnu dot org
@ 2005-05-11 9:07 ` rguenth at gcc dot gnu dot org
2005-05-11 9:08 ` rguenth at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-05-11 9:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-05-11 09:07 -------
Fixed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19807
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/19807] fold does not fold &a[4]-1
2005-02-07 23:13 [Bug middle-end/19807] New: fold does not fold &a[4]-1 rguenth at gcc dot gnu dot org
` (7 preceding siblings ...)
2005-05-11 9:07 ` rguenth at gcc dot gnu dot org
@ 2005-05-11 9:08 ` rguenth at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-05-11 9:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-05-11 09:08 -------
Always forget to set target milestone.
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19807
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2005-05-11 9:08 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-07 23:13 [Bug middle-end/19807] New: fold does not fold &a[4]-1 rguenth at gcc dot gnu dot org
2005-02-07 23:15 ` [Bug middle-end/19807] " rguenth at gcc dot gnu dot org
2005-02-07 23:16 ` rguenth at gcc dot gnu dot org
2005-02-08 2:34 ` pinskia at gcc dot gnu dot org
2005-02-09 17:40 ` rguenth at gcc dot gnu dot org
2005-04-23 21:37 ` rguenth at gcc dot gnu dot org
2005-04-25 14:49 ` pinskia at gcc dot gnu dot org
2005-05-11 8:15 ` cvs-commit at gcc dot gnu dot org
2005-05-11 9:07 ` rguenth at gcc dot gnu dot org
2005-05-11 9:08 ` 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).