public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/15255] New: [tree-ssa] a * 2 + a * 2 is not converted to a * 4
@ 2004-05-03 7:14 kazu at cs dot umass dot edu
2004-05-03 11:24 ` [Bug optimization/15255] " pinskia at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-03 7:14 UTC (permalink / raw)
To: gcc-bugs
int
foo (int a)
{
return a * 2 + a * 2;
}
The last SSA form looks like:
foo (a)
{
int T.0;
<bb 0>:
T.0_2 = a_1 + a_1;
return T.0_2 * 2;
}
Why not return a_1 * 4?
Interestingly, a * 3 + a * 5 is converted to a * 8, but if I compute like so
int
foo (int a)
{
int b = a * 3;
int c = a * 5;
return b + c;
}
I get:
b_2 = a_1 * 3;
c_3 = a_1 * 5;
return b_2 + c_3;
--
Summary: [tree-ssa] a * 2 + a * 2 is not converted to a * 4
Product: gcc
Version: tree-ssa
Status: UNCONFIRMED
Keywords: pessimizes-code
Severity: enhancement
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kazu at cs dot umass dot edu
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
2004-05-03 7:14 [Bug optimization/15255] New: [tree-ssa] a * 2 + a * 2 is not converted to a * 4 kazu at cs dot umass dot edu
@ 2004-05-03 11:24 ` pinskia at gcc dot gnu dot org
2004-05-24 21:23 ` [Bug tree-optimization/15255] " pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-03 11:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-03 11:24 -------
Confirmed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-05-03 11:24:24
date| |
Target Milestone|--- |tree-ssa
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
2004-05-03 7:14 [Bug optimization/15255] New: [tree-ssa] a * 2 + a * 2 is not converted to a * 4 kazu at cs dot umass dot edu
2004-05-03 11:24 ` [Bug optimization/15255] " pinskia at gcc dot gnu dot org
@ 2004-05-24 21:23 ` pinskia at gcc dot gnu dot org
2004-05-25 14:30 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-24 21:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-24 01:26 -------
Mine as this will get fixed when 15459 gets fixed.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pinskia at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
2004-05-03 7:14 [Bug optimization/15255] New: [tree-ssa] a * 2 + a * 2 is not converted to a * 4 kazu at cs dot umass dot edu
2004-05-03 11:24 ` [Bug optimization/15255] " pinskia at gcc dot gnu dot org
2004-05-24 21:23 ` [Bug tree-optimization/15255] " pinskia at gcc dot gnu dot org
@ 2004-05-25 14:30 ` pinskia at gcc dot gnu dot org
2004-05-27 8:36 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-25 14:30 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-24 15:57 -------
The first one is because fold converted it to be (a + a) * 2 but fold should be doing this conversion. PR
15459 fixes the other problem in the PR, I will submitting a new patch today with more comments and
more like the RTL combiner.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
2004-05-03 7:14 [Bug optimization/15255] New: [tree-ssa] a * 2 + a * 2 is not converted to a * 4 kazu at cs dot umass dot edu
` (2 preceding siblings ...)
2004-05-25 14:30 ` pinskia at gcc dot gnu dot org
@ 2004-05-27 8:36 ` pinskia at gcc dot gnu dot org
2004-06-21 5:13 ` pinskia at gcc dot gnu dot org
2005-02-16 4:22 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-27 8:36 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.5.0 |---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
2004-05-03 7:14 [Bug optimization/15255] New: [tree-ssa] a * 2 + a * 2 is not converted to a * 4 kazu at cs dot umass dot edu
` (3 preceding siblings ...)
2004-05-27 8:36 ` pinskia at gcc dot gnu dot org
@ 2004-06-21 5:13 ` pinskia at gcc dot gnu dot org
2005-02-16 4:22 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-21 5:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-06-21 05:13 -------
I will submit my patch tree combine patch tonight which fixes the second case but not the first as the
first is a problem in fold.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
2004-05-03 7:14 [Bug optimization/15255] New: [tree-ssa] a * 2 + a * 2 is not converted to a * 4 kazu at cs dot umass dot edu
` (4 preceding siblings ...)
2004-06-21 5:13 ` pinskia at gcc dot gnu dot org
@ 2005-02-16 4:22 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-16 4:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-02-15 22:22 -------
As I said before I was not going to fix a fold problem (for the first testcase).
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|pinskia at gcc dot gnu dot |unassigned at gcc dot gnu
|org |dot org
Status|ASSIGNED |NEW
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
[not found] <bug-15255-4@http.gcc.gnu.org/bugzilla/>
@ 2014-10-31 4:02 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-10-31 4:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
Bug 15255 depends on bug 15459, which changed state.
Bug 15459 Summary: [meta-bug] there should be a tree combiner like the rtl one
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15459
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
[not found] <bug-15255-5009@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2008-08-13 9:00 ` rguenth at gcc dot gnu dot org
@ 2008-08-13 9:02 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-08-13 9:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from rguenth at gcc dot gnu dot org 2008-08-13 09:00 -------
Fixed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
[not found] <bug-15255-5009@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2008-04-29 16:04 ` rguenth at gcc dot gnu dot org
@ 2008-08-13 9:00 ` rguenth at gcc dot gnu dot org
2008-08-13 9:02 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-08-13 9:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from rguenth at gcc dot gnu dot org 2008-08-13 08:58 -------
Subject: Bug 15255
Author: rguenth
Date: Wed Aug 13 08:57:20 2008
New Revision: 139048
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139048
Log:
2008-08-13 Richard Guenther <rguenther@suse.de>
PR tree-optimization/15255
* tree-ssa-reassoc.c (linearize_expr_tree): Declare.
(struct oecount_s): New struct and VEC types.
(cvec): New global.
(oecount_hash): New function.
(oecount_eq): Likewise.
(oecount_cmp): Likewise.
(zero_one_operation): New function.
(build_and_add_sum): Likewise.
(undistribute_ops_list): Perform un-distribution of multiplication
and division on the chain of summands.
(should_break_up_subtract): Also break up subtracts for factors.
(reassociate_bb): Delete dead visited statements.
Call undistribute_ops_list. Re-sort and optimize if it did something.
* passes.c (init_optimization_passes): Move DSE before
reassociation.
* tree-ssa-loop-niter.c (stmt_dominates_stmt_p): Correctly handle
PHI nodes.
* gcc.dg/tree-ssa/reassoc-14.c: New testcase.
* gcc.dg/tree-ssa/reassoc-15.c: Likewise.
* gcc.dg/tree-ssa/reassoc-16.c: Likewise.
* gcc.dg/torture/reassoc-1.c: Likewise.
* gcc.dg/tree-ssa/recip-2.c: Adjust.
* gcc.dg/tree-ssa/recip-6.c: Likewise.
* gcc.dg/tree-ssa/recip-7.c: Likewise.
* gfortran.dg/reassoc_4.f: Likewise.
Added:
trunk/gcc/testsuite/gcc.dg/torture/reassoc-1.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-14.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-15.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-16.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-17.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-18.c
trunk/gcc/testsuite/gfortran.dg/reassoc_4.f
Modified:
trunk/gcc/ChangeLog
trunk/gcc/passes.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/tree-ssa/recip-2.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/recip-6.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/recip-7.c
trunk/gcc/tree-ssa-loop-niter.c
trunk/gcc/tree-ssa-reassoc.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
[not found] <bug-15255-5009@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2008-04-29 16:01 ` rguenth at gcc dot gnu dot org
@ 2008-04-29 16:04 ` rguenth at gcc dot gnu dot org
2008-08-13 9:00 ` rguenth at gcc dot gnu dot org
2008-08-13 9:02 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-29 16:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from rguenth at gcc dot gnu dot org 2008-04-29 16:03 -------
The fold missed optimizations are fixed.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
[not found] <bug-15255-5009@http.gcc.gnu.org/bugzilla/>
2008-04-28 20:20 ` rguenth at gcc dot gnu dot org
2008-04-29 14:18 ` rguenth at gcc dot gnu dot org
@ 2008-04-29 16:01 ` rguenth at gcc dot gnu dot org
2008-04-29 16:04 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-29 16:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from rguenth at gcc dot gnu dot org 2008-04-29 16:00 -------
Subject: Bug 15255
Author: rguenth
Date: Tue Apr 29 15:59:43 2008
New Revision: 134798
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134798
Log:
2008-04-29 Richard Guenther <rguenther@suse.de>
PR middle-end/15255
* fold-const.c (fold_binary): Fold (A + A) * C to A * 2*C.
* gcc.dg/fold-plusmult.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.dg/fold-plusmult.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fold-const.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
[not found] <bug-15255-5009@http.gcc.gnu.org/bugzilla/>
2008-04-28 20:20 ` rguenth at gcc dot gnu dot org
@ 2008-04-29 14:18 ` rguenth at gcc dot gnu dot org
2008-04-29 16:01 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-29 14:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rguenth at gcc dot gnu dot org 2008-04-29 14:17 -------
We already handle most of the foldings in fold_plusminus_mult_expr, just the
A + A -> 2 * A folding is not done (for a reason).
We also miss (A + A) * Cst -> A * 2 * Cst, which is what I am going to
implement
in addition to extending the tree re-association pass.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/15255] [tree-ssa] a * 2 + a * 2 is not converted to a * 4
[not found] <bug-15255-5009@http.gcc.gnu.org/bugzilla/>
@ 2008-04-28 20:20 ` rguenth at gcc dot gnu dot org
2008-04-29 14:18 ` rguenth at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-28 20:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from rguenth at gcc dot gnu dot org 2008-04-28 20:19 -------
Mine.
--
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-02-20 18:43:31 |2008-04-28 20:19:51
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15255
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-10-31 4:02 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-03 7:14 [Bug optimization/15255] New: [tree-ssa] a * 2 + a * 2 is not converted to a * 4 kazu at cs dot umass dot edu
2004-05-03 11:24 ` [Bug optimization/15255] " pinskia at gcc dot gnu dot org
2004-05-24 21:23 ` [Bug tree-optimization/15255] " pinskia at gcc dot gnu dot org
2004-05-25 14:30 ` pinskia at gcc dot gnu dot org
2004-05-27 8:36 ` pinskia at gcc dot gnu dot org
2004-06-21 5:13 ` pinskia at gcc dot gnu dot org
2005-02-16 4:22 ` pinskia at gcc dot gnu dot org
[not found] <bug-15255-5009@http.gcc.gnu.org/bugzilla/>
2008-04-28 20:20 ` rguenth at gcc dot gnu dot org
2008-04-29 14:18 ` rguenth at gcc dot gnu dot org
2008-04-29 16:01 ` rguenth at gcc dot gnu dot org
2008-04-29 16:04 ` rguenth at gcc dot gnu dot org
2008-08-13 9:00 ` rguenth at gcc dot gnu dot org
2008-08-13 9:02 ` rguenth at gcc dot gnu dot org
[not found] <bug-15255-4@http.gcc.gnu.org/bugzilla/>
2014-10-31 4:02 ` pinskia 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).