public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/23294] New: fold does not fold a*2-a to a
@ 2005-08-09 3:06 pinskia at gcc dot gnu dot org
2005-08-10 0:45 ` [Bug middle-end/23294] " pinskia at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-09 3:06 UTC (permalink / raw)
To: gcc-bugs
I noticed this while running a profiledbootstrap and looking through simplify-rtx.c.
Take the following function:
int f(int a)
{
return a*2-a;
}
We don't optimizate a*2-a to just a on the tree level but do in combine, we do.
--
Summary: fold does not fold a*2-a to a
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: missed-optimization, TREE
Severity: enhancement
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
OtherBugsDependingO 19986
nThis:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23294
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/23294] fold does not fold a*2-a to a
2005-08-09 3:06 [Bug middle-end/23294] New: fold does not fold a*2-a to a pinskia at gcc dot gnu dot org
@ 2005-08-10 0:45 ` pinskia at gcc dot gnu dot org
2005-08-10 0:49 ` [Bug middle-end/23294] fold does not fold a*C+a to a*(C+1) or a*C-a to a*(C-1) pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-10 0:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-10 00:45 -------
Here is an example which is __not__ folded back and shows that we don't optimize it on the RTL level at
least for i686:
int f(int a)
{
return a*6-a;
}
int f1(int a)
{
return a*5;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23294
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/23294] fold does not fold a*C+a to a*(C+1) or a*C-a to a*(C-1)
2005-08-09 3:06 [Bug middle-end/23294] New: fold does not fold a*2-a to a pinskia at gcc dot gnu dot org
2005-08-10 0:45 ` [Bug middle-end/23294] " pinskia at gcc dot gnu dot org
@ 2005-08-10 0:49 ` pinskia at gcc dot gnu dot org
2005-08-10 9:24 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-10 0:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-10 00:49 -------
Confirmed.
a*C+a is also not simplified.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-08-10 00:49:31
date| |
Summary|fold does not fold a*2-a to |fold does not fold a*C+a to
|a |a*(C+1) or a*C-a to a*(C-1)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23294
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/23294] fold does not fold a*C+a to a*(C+1) or a*C-a to a*(C-1)
2005-08-09 3:06 [Bug middle-end/23294] New: fold does not fold a*2-a to a pinskia at gcc dot gnu dot org
2005-08-10 0:45 ` [Bug middle-end/23294] " pinskia at gcc dot gnu dot org
2005-08-10 0:49 ` [Bug middle-end/23294] fold does not fold a*C+a to a*(C+1) or a*C-a to a*(C-1) pinskia at gcc dot gnu dot org
@ 2005-08-10 9:24 ` rguenth at gcc dot gnu dot org
2005-08-10 10:27 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-08-10 9:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-08-10 09:23 -------
I believe we can only do so for -fwrapv (but we don't) or for unsigned (which we
also don't do). I may look at this somewhen in the future.
We also don't canonicalize
int f(int a)
{
return a + a + a;
}
which I believe we did at some time?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23294
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/23294] fold does not fold a*C+a to a*(C+1) or a*C-a to a*(C-1)
2005-08-09 3:06 [Bug middle-end/23294] New: fold does not fold a*2-a to a pinskia at gcc dot gnu dot org
` (2 preceding siblings ...)
2005-08-10 9:24 ` rguenth at gcc dot gnu dot org
@ 2005-08-10 10:27 ` pinskia at gcc dot gnu dot org
2005-08-26 9:35 ` rguenth at gcc dot gnu dot org
2005-08-26 13:57 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-10 10:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-10 10:26 -------
(In reply to comment #3)
> I believe we can only do so for -fwrapv (but we don't) or for unsigned (which we
> also don't do). I may look at this somewhen in the future.
Why do you believe that with -fno-wrapv, overflow is undefined so anything can happen.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23294
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/23294] fold does not fold a*C+a to a*(C+1) or a*C-a to a*(C-1)
2005-08-09 3:06 [Bug middle-end/23294] New: fold does not fold a*2-a to a pinskia at gcc dot gnu dot org
` (3 preceding siblings ...)
2005-08-10 10:27 ` pinskia at gcc dot gnu dot org
@ 2005-08-26 9:35 ` rguenth at gcc dot gnu dot org
2005-08-26 13:57 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-08-26 9:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-08-26 09:34 -------
I have a patch.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2005-08-10 00:49:31 |2005-08-26 09:34:08
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23294
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/23294] fold does not fold a*C+a to a*(C+1) or a*C-a to a*(C-1)
2005-08-09 3:06 [Bug middle-end/23294] New: fold does not fold a*2-a to a pinskia at gcc dot gnu dot org
` (4 preceding siblings ...)
2005-08-26 9:35 ` rguenth at gcc dot gnu dot org
@ 2005-08-26 13:57 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-08-26 13:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-08-26 13:50 -------
Patch posted.
--
What |Removed |Added
----------------------------------------------------------------------------
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2005-
| |08/msg01555.html
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23294
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/23294] fold does not fold a*C+a to a*(C+1) or a*C-a to a*(C-1)
[not found] <bug-23294-6528@http.gcc.gnu.org/bugzilla/>
2005-11-19 11:29 ` rguenth at gcc dot gnu dot org
@ 2005-11-19 11:31 ` rguenth at gcc dot gnu dot org
1 sibling, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-11-19 11:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rguenth at gcc dot gnu dot org 2005-11-19 11:31 -------
Fixed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23294
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/23294] fold does not fold a*C+a to a*(C+1) or a*C-a to a*(C-1)
[not found] <bug-23294-6528@http.gcc.gnu.org/bugzilla/>
@ 2005-11-19 11:29 ` rguenth at gcc dot gnu dot org
2005-11-19 11:31 ` rguenth at gcc dot gnu dot org
1 sibling, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-11-19 11:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from rguenth at gcc dot gnu dot org 2005-11-19 11:29 -------
Subject: Bug 23294
Author: rguenth
Date: Sat Nov 19 11:29:10 2005
New Revision: 107218
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107218
Log:
2005-11-19 Richard Guenther <rguenther@suse.de>
PR middle-end/23294
* fold-const.c (fold_plusminus_mult_expr): New function.
(fold_binary): Use to canonicalize PLUS_EXPR and MINUS_EXPR
cases, remove now unnecessary code.
* gcc.dg/tree-ssa/pr23294.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr23294.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fold-const.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23294
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-11-19 11:31 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-09 3:06 [Bug middle-end/23294] New: fold does not fold a*2-a to a pinskia at gcc dot gnu dot org
2005-08-10 0:45 ` [Bug middle-end/23294] " pinskia at gcc dot gnu dot org
2005-08-10 0:49 ` [Bug middle-end/23294] fold does not fold a*C+a to a*(C+1) or a*C-a to a*(C-1) pinskia at gcc dot gnu dot org
2005-08-10 9:24 ` rguenth at gcc dot gnu dot org
2005-08-10 10:27 ` pinskia at gcc dot gnu dot org
2005-08-26 9:35 ` rguenth at gcc dot gnu dot org
2005-08-26 13:57 ` rguenth at gcc dot gnu dot org
[not found] <bug-23294-6528@http.gcc.gnu.org/bugzilla/>
2005-11-19 11:29 ` rguenth at gcc dot gnu dot org
2005-11-19 11:31 ` 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).