public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/20580] New: Using ASSERT_EXPR to improve constant propagation of conditional constants
@ 2005-03-21 18:40 steven at gcc dot gnu dot org
2005-03-21 18:41 ` [Bug tree-optimization/20580] " steven at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-03-21 18:40 UTC (permalink / raw)
To: gcc-bugs
This is an enhancement request for constant propagation on the
tree-cleanup-branch. Consider the following small test case:
int foo (int a, int b) {
if (a || b) {
a = 3;
return a + b;
}
return a + b;
}
We currently compile this to the following .optimized dump:
foo (a, b)
{
int D.1465;
int D.1464;
<bb 0>:
if ((a | b) != 0) goto <L0>; else goto <L1>;
<L0>:;
D.1465 = b + 3;
goto <bb 3> (<L2>);
<L1>:;
D.1465 = a + b; /* Ah-ha! But we know both a and b must be 0! */
<L2>:;
return D.1465;
}
Notice the "D.1465 = a + b;". We can know that both a and b are 0 at
this point, or the condition "(a | b)" could not have been false. So
this test case could be optimized to something like this:
foo (a, b)
{
int D.1465;
int D.1464;
<bb 0>:
if ((a | b) != 0) goto <L0>; else goto <L1>;
<L0>:;
D.1465 = b + 3;
goto <bb 3> (<L2>);
<L1>:;
D.1465 = 0;
<L2>:;
return D.1465;
}
In the traditional SSA-CCP algorithm this is actually difficult to do,
but on the tree-cleanup-branch, we can insert ASSERT_EXPRs for a and b
in the false arm of the conditional:
foo (a, b)
{
int D.1465;
int D.1464;
<bb 0>:
D.1464_4 = a_2 | b_3;
if (D.1464_4 != 0) goto <L0>; else goto <L1>;
<L0>:;
D.1465_8 = b_3 + 3;
goto <bb 3> (<L2>);
<L1>:;
a_7 = ASSERT_EXPR <a_2, 0>;
b_8 = ASSERT_EXPR <a_3, 0>
D.1465_6 = a_7 + b_8;
# D.1465_1 = PHI <D.1465_8(1), D.1465_6(2)>;
<L2>:;
return D.1465_1;
}
This should allow us to propagate more constants.
--
Summary: Using ASSERT_EXPR to improve constant propagation of
conditional constants
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: missed-optimization, TREE
Severity: enhancement
Priority: P2
Component: tree-optimization
AssignedTo: dnovillo at gcc dot gnu dot org
ReportedBy: steven at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20580
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/20580] Using ASSERT_EXPR to improve constant propagation of conditional constants
2005-03-21 18:40 [Bug tree-optimization/20580] New: Using ASSERT_EXPR to improve constant propagation of conditional constants steven at gcc dot gnu dot org
@ 2005-03-21 18:41 ` steven at gcc dot gnu dot org
2005-03-22 20:50 ` kazu at cs dot umass dot edu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-03-21 18:41 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From steven at gcc dot gnu dot org 2005-03-21 18:41 -------
This should be fairly trivial to do on the tree-cleanup-branch, so this
is "fixable" for GCC 4.1. Let's hope it gives a real improvement... ;-)
Confirmed because I already discussed this idea with Diego.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-03-21 18:41:06
date| |
Target Milestone|--- |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20580
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/20580] Using ASSERT_EXPR to improve constant propagation of conditional constants
2005-03-21 18:40 [Bug tree-optimization/20580] New: Using ASSERT_EXPR to improve constant propagation of conditional constants steven at gcc dot gnu dot org
2005-03-21 18:41 ` [Bug tree-optimization/20580] " steven at gcc dot gnu dot org
@ 2005-03-22 20:50 ` kazu at cs dot umass dot edu
2005-04-05 2:00 ` pinskia at gcc dot gnu dot org
2005-06-04 16:47 ` dnovillo at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-03-22 20:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kazu at cs dot umass dot edu 2005-03-22 20:50 -------
We probably need something like substitute_and_fold for VRP as well.
Otherwise, we can't fold a + b into 0.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20580
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/20580] Using ASSERT_EXPR to improve constant propagation of conditional constants
2005-03-21 18:40 [Bug tree-optimization/20580] New: Using ASSERT_EXPR to improve constant propagation of conditional constants steven at gcc dot gnu dot org
2005-03-21 18:41 ` [Bug tree-optimization/20580] " steven at gcc dot gnu dot org
2005-03-22 20:50 ` kazu at cs dot umass dot edu
@ 2005-04-05 2:00 ` pinskia at gcc dot gnu dot org
2005-06-04 16:47 ` dnovillo at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-05 2:00 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.1.0 |---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20580
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/20580] Using ASSERT_EXPR to improve constant propagation of conditional constants
2005-03-21 18:40 [Bug tree-optimization/20580] New: Using ASSERT_EXPR to improve constant propagation of conditional constants steven at gcc dot gnu dot org
` (2 preceding siblings ...)
2005-04-05 2:00 ` pinskia at gcc dot gnu dot org
@ 2005-06-04 16:47 ` dnovillo at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: dnovillo at gcc dot gnu dot org @ 2005-06-04 16:47 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dnovillo at gcc dot gnu dot org 2005-06-04 16:47 -------
Fixed with http://gcc.gnu.org/ml/gcc-patches/2005-06/msg00127.html
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20580
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-06-04 16:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-21 18:40 [Bug tree-optimization/20580] New: Using ASSERT_EXPR to improve constant propagation of conditional constants steven at gcc dot gnu dot org
2005-03-21 18:41 ` [Bug tree-optimization/20580] " steven at gcc dot gnu dot org
2005-03-22 20:50 ` kazu at cs dot umass dot edu
2005-04-05 2:00 ` pinskia at gcc dot gnu dot org
2005-06-04 16:47 ` dnovillo 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).