public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
[parent not found: <bug-15353-4@http.gcc.gnu.org/bugzilla/>]
[parent not found: <20040509200719.15353.kazu@gcc.gnu.org>]
* [Bug tree-optimization/15353] [tree-ssa] Merge two "if"s if one subsumes the other.
[not found] <20040509200719.15353.kazu@gcc.gnu.org>
@ 2005-08-10 18:57 ` law at redhat dot com
2005-08-11 11:01 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: law at redhat dot com @ 2005-08-10 18:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From law at redhat dot com 2005-08-10 18:57 -------
Subject: Re: [tree-ssa] Merge two "if"s if
one subsumes the other.
On Sat, 2005-06-11 at 19:16 +0000, pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-11 19:16 -------
> (In reply to comment #3)
> > And it should merge them, too, like for
>
> I better testcase which shows why we don't convert i > j || i == j into i >= j
> which is reduced from Richard's tramp3d:
> int g(void);
> int h(void);
> int f(int *i, int *j)
> {
> while (1)
> {
> if (*i > *j || *i == *j)
> break;
> return g();
> }
> return h();
> }
At first I thought we might be able to do this via VRP. But after more
thought, I don't see this kind of transformation fitting into the VRP
framework.
It wouldn't be terribly hard to write a new optimizer to perform this
transformation, and I would expect it would be pretty efficient. It
would need to run after copy propagation and DCE since useless
copies would easily get in the way of successful optimization.
I'm pretty sure it could be done with a single pass through the IL.
Jeff
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15353
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/15353] [tree-ssa] Merge two "if"s if one subsumes the other.
[not found] <20040509200719.15353.kazu@gcc.gnu.org>
2005-08-10 18:57 ` law at redhat dot com
@ 2005-08-11 11:01 ` rguenth at gcc dot gnu dot org
2005-08-11 15:43 ` law at redhat dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-08-11 11:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-08-11 11:01 -------
Couldn't DOM do this at jump threading time? I.e.
if (D.1286_3 > D.1287_5) goto <L3>; else goto <L1>;
<L1>:;
if (D.1286_3 == D.1287_5) goto <L3>; else goto <L2>;
during trying of threading through the jump at L1 merge the
two conditionals?
Just guessing...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15353
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/15353] [tree-ssa] Merge two "if"s if one subsumes the other.
[not found] <20040509200719.15353.kazu@gcc.gnu.org>
2005-08-10 18:57 ` law at redhat dot com
2005-08-11 11:01 ` rguenth at gcc dot gnu dot org
@ 2005-08-11 15:43 ` law at redhat dot com
2005-08-11 15:52 ` trt at acm dot org
2005-08-11 17:29 ` law at redhat dot com
4 siblings, 0 replies; 12+ messages in thread
From: law at redhat dot com @ 2005-08-11 15:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From law at redhat dot com 2005-08-11 15:43 -------
Subject: Re: [tree-ssa] Merge two "if"s if
one subsumes the other.
On Thu, 2005-08-11 at 11:01 +0000, rguenth at gcc dot gnu dot org wrote:
> ------- Additional Comments From rguenth at gcc dot gnu dot org 2005-08-11 11:01 -------
> Couldn't DOM do this at jump threading time? I.e.
>
> if (D.1286_3 > D.1287_5) goto <L3>; else goto <L1>;
>
> <L1>:;
> if (D.1286_3 == D.1287_5) goto <L3>; else goto <L2>;
>
> during trying of threading through the jump at L1 merge the
> two conditionals?
Jump threading isn't particularly well suited for this kind of
optimization.
jeff
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15353
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/15353] [tree-ssa] Merge two "if"s if one subsumes the other.
[not found] <20040509200719.15353.kazu@gcc.gnu.org>
` (2 preceding siblings ...)
2005-08-11 15:43 ` law at redhat dot com
@ 2005-08-11 15:52 ` trt at acm dot org
2005-08-11 17:29 ` law at redhat dot com
4 siblings, 0 replies; 12+ messages in thread
From: trt at acm dot org @ 2005-08-11 15:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From trt at acm dot org 2005-08-11 15:52 -------
I think http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21643 is closely related.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15353
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/15353] [tree-ssa] Merge two "if"s if one subsumes the other.
[not found] <20040509200719.15353.kazu@gcc.gnu.org>
` (3 preceding siblings ...)
2005-08-11 15:52 ` trt at acm dot org
@ 2005-08-11 17:29 ` law at redhat dot com
4 siblings, 0 replies; 12+ messages in thread
From: law at redhat dot com @ 2005-08-11 17:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From law at redhat dot com 2005-08-11 17:29 -------
Subject: Re: [tree-ssa] Merge two "if"s if
one subsumes the other.
On Thu, 2005-08-11 at 15:52 +0000, trt at acm dot org wrote:
> ------- Additional Comments From trt at acm dot org 2005-08-11 15:52 -------
> I think http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21643 is closely related.
It's related.
However, there is a key difference. In 21643, the object being tested
is a scalar and thus should be subject to optimization by fold-const.c's
range checking optimizations. ie, the merging of the conditions in the
test should occur well before the SSA optimization path is run.
In 15353 the object being tested is a memory reference and thus we can
not safely merge the tests until later in the optimization path (after
we've exposed the memory loads and proved they're equivalent).
jeff
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15353
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug optimization/15353] New: [tree-ssa] Merge two "if"s if one subsumes the other.
@ 2004-05-09 20:07 kazu at cs dot umass dot edu
2004-05-25 0:03 ` [Bug tree-optimization/15353] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-09 20:07 UTC (permalink / raw)
To: gcc-bugs
void bar (void);
void
foo (int a, int b)
{
do
{
if (a < b)
break;
if (a != b)
break;
bar ();
}
while (0);
}
I get:
foo (a, b)
{
<bb 0>:
if (a_1 < b_2) goto <L2>; else goto <L0>;
<L0>:;
if (a_1 != b_2) goto <L2>; else goto <L1>;
<L1>:;
bar () [tail call];
<L2>:;
return;
}
Note that the second "if" completely subsumes the first.
We would like:
foo (a, b)
{
<bb 0>:
if (a_1 == b_2) goto <L0>; else goto <L1>;
<L0>:;
bar () [tail call];
<L1>:;
return;
}
This comes from shorten_compare from c-common.c.
--
Summary: [tree-ssa] Merge two "if"s if one subsumes the other.
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=15353
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-11-09 20:39 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-15353-5009@http.gcc.gnu.org/bugzilla/>
2007-04-23 11:48 ` [Bug tree-optimization/15353] [tree-ssa] Merge two "if"s if one subsumes the other rguenth at gcc dot gnu dot org
2007-06-12 12:06 ` rguenth at gcc dot gnu dot org
2007-06-12 12:08 ` rguenth at gcc dot gnu dot org
[not found] <bug-15353-4@http.gcc.gnu.org/bugzilla/>
2013-11-09 20:40 ` pinskia at gcc dot gnu.org
[not found] <20040509200719.15353.kazu@gcc.gnu.org>
2005-08-10 18:57 ` law at redhat dot com
2005-08-11 11:01 ` rguenth at gcc dot gnu dot org
2005-08-11 15:43 ` law at redhat dot com
2005-08-11 15:52 ` trt at acm dot org
2005-08-11 17:29 ` law at redhat dot com
2004-05-09 20:07 [Bug optimization/15353] New: " kazu at cs dot umass dot edu
2004-05-25 0:03 ` [Bug tree-optimization/15353] " pinskia at gcc dot gnu dot org
2005-06-11 19:06 ` rguenth at gcc dot gnu dot org
2005-06-11 19:16 ` pinskia 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).