public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/14495] [tree-ssa] Propagate range info into a switch statement
[not found] <bug-14495-5009@http.gcc.gnu.org/bugzilla/>
@ 2006-04-20 10:58 ` wouter dot vermaelen at pi dot be
2007-04-13 9:31 ` rguenth at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: wouter dot vermaelen at pi dot be @ 2006-04-20 10:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from wouter dot vermaelen at pi dot be 2006-04-20 10:58 -------
I think something similar happens for the following code.
int f(int a) {
switch (a & 7) {
case 0: return 2;
case 1: return 3;
case 2: return 5;
case 3: return 7;
case 4: return 11;
case 5: return 13;
case 6: return 17;
case 7: return 19;
}
}
Part of the generated code looks like this:
movl 8(%ebp), %eax
andl $7, %eax
cmpl $7, %eax
jbe .L15
popl %ebp
ret
.p2align 4,,15
.L15:
jmp *.L11(,%eax,4)
The test for values bigger than 7 is clearly not needed here.
I don't know much about compiler technologie, but maybe this specific case is
easier to solve with some peephole optimization?
I have seen real code (Z80 emulator or HQ2x scaler algorithm) that does a
switch on a unsigned char and handles all 256 cases. Code like that would
benefit from this optimization.
Thanks.
--
wouter dot vermaelen at pi dot be changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wouter dot vermaelen at pi
| |dot be
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14495
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/14495] [tree-ssa] Propagate range info into a switch statement
[not found] <bug-14495-5009@http.gcc.gnu.org/bugzilla/>
2006-04-20 10:58 ` [Bug tree-optimization/14495] [tree-ssa] Propagate range info into a switch statement wouter dot vermaelen at pi dot be
@ 2007-04-13 9:31 ` rguenth at gcc dot gnu dot org
2007-04-17 13:05 ` patchapp at dberlin dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-13 9:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenth at gcc dot gnu dot org 2007-04-13 10:31 -------
I have a patch to handle the ONE edge case.
--
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-03-05 17:19:18 |2007-04-13 10:31:07
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14495
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/14495] [tree-ssa] Propagate range info into a switch statement
[not found] <bug-14495-5009@http.gcc.gnu.org/bugzilla/>
2006-04-20 10:58 ` [Bug tree-optimization/14495] [tree-ssa] Propagate range info into a switch statement wouter dot vermaelen at pi dot be
2007-04-13 9:31 ` rguenth at gcc dot gnu dot org
@ 2007-04-17 13:05 ` patchapp at dberlin dot org
2008-04-02 12:53 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: patchapp at dberlin dot org @ 2007-04-17 13:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from patchapp at dberlin dot org 2007-04-17 14:05 -------
Subject: Bug number PR14495
A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-04/msg01072.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14495
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/14495] [tree-ssa] Propagate range info into a switch statement
[not found] <bug-14495-5009@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2007-04-17 13:05 ` patchapp at dberlin dot org
@ 2008-04-02 12:53 ` rguenth at gcc dot gnu dot org
2008-04-02 12:55 ` rguenth at gcc dot gnu dot org
2008-04-02 12:56 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-02 12:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rguenth at gcc dot gnu dot org 2008-04-02 12:52 -------
Subject: Bug 14495
Author: rguenth
Date: Wed Apr 2 12:51:37 2008
New Revision: 133834
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133834
Log:
2008-04-02 Richard Guenther <rguenther@suse.de>
PR tree-optimization/14495
* tree-vrp.c (vrp_visit_cond_stmt): Do not handle
SWITCH_EXPR here ...
(vrp_visit_switch_stmt): ... but here (new function).
(find_case_label_index): New helper function.
(vrp_visit_stmt): Dispatch to vrp_visit_switch_stmt.
* gcc.dg/tree-ssa/vrp40.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp40.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-vrp.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14495
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/14495] [tree-ssa] Propagate range info into a switch statement
[not found] <bug-14495-5009@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2008-04-02 12:53 ` rguenth at gcc dot gnu dot org
@ 2008-04-02 12:55 ` rguenth at gcc dot gnu dot org
2008-04-02 12:56 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-02 12:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from rguenth at gcc dot gnu dot org 2008-04-02 12:54 -------
Subject: Bug 14495
Author: rguenth
Date: Wed Apr 2 12:54:08 2008
New Revision: 133835
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133835
Log:
2008-04-02 Richard Guenther <rguenther@suse.de>
PR tree-optimization/14495
PR tree-optimization/34793
* tree-vrp.c (struct switch_update): New structure.
(to_remove_edges, to_update_switch_stmts): New VECs.
(simplify_switch_using_ranges): New function. Remove not taken
case labels and edges.
(simplify_stmt_using_ranges): Call it.
(identify_jump_threads): Mark edges we have queued for removal
so we don't thread them.
(execute_vrp): Remove edges queued for removal, update SWITCH_STMT
case label vector.
* tree-cfg.c (group_case_labels): Deal with missing default label.
(tree_verify_flow_info): Allow missing default label.
* stmt.c (emit_case_bit_tests): Deal with NULL default_label.
(emit_case_nodes): Likewise.
(expand_case): Do not rely on the default label to be present.
* expr.c (try_casesi): Deal with NULL default_label.
(do_tablejump): Likewise.
* gcc.dg/tree-ssa/vrp41.c: New testcase.
* gcc.dg/tree-ssa/vrp42.c: Likewise.
Added:
trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp41.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp42.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/expr.c
trunk/gcc/stmt.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-cfg.c
trunk/gcc/tree-vrp.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14495
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/14495] [tree-ssa] Propagate range info into a switch statement
[not found] <bug-14495-5009@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2008-04-02 12:55 ` rguenth at gcc dot gnu dot org
@ 2008-04-02 12:56 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-02 12:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from rguenth at gcc dot gnu dot org 2008-04-02 12:55 -------
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=14495
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <20040309003513.14495.kazu@gcc.gnu.org>]
* [Bug optimization/14495] New: [tree-ssa] Propagate range info into a switch statement
@ 2004-03-09 0:35 kazu at cs dot umass dot edu
2004-05-24 15:57 ` [Bug tree-optimization/14495] " pinskia at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-03-09 0:35 UTC (permalink / raw)
To: gcc-bugs
Consider:
void bar0 (void);
void bar1 (void);
void bar2 (void);
void bar3 (void);
void
foo (int a)
{
if (a < 100)
return;
if (200 < a)
return;
switch (a)
{
case 99: bar0 (); return;
case 100: bar1 (); return;
case 101: bar2 (); return;
case 102: bar3 (); return;
}
}
case 99 won't trigger, but I still get:
foo (a)
{
<bb 0>:
if (a <= 99) goto <L0>; else goto <L1>;
<L0>:;
return;
<L1>:;
if (a > 200) goto <L2>; else goto <L3>;
<L2>:;
return;
<L3>:;
switch (a)
{
case 99: goto <L4>;
case 100: goto <L5>;
case 101: goto <L6>;
case 102: goto <L7>;
default : goto <L8>;
}
<L4>:;
bar0 () [tail call];
return;
<L5>:;
bar1 () [tail call];
return;
<L6>:;
bar2 () [tail call];
return;
<L7>:;
bar3 () [tail call];
return;
<L8>:;
return;
}
--
Summary: [tree-ssa] Propagate range info into a switch statement
Product: gcc
Version: tree-ssa
Status: UNCONFIRMED
Keywords: pessimizes-code
Severity: normal
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=14495
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-04-02 12:56 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-14495-5009@http.gcc.gnu.org/bugzilla/>
2006-04-20 10:58 ` [Bug tree-optimization/14495] [tree-ssa] Propagate range info into a switch statement wouter dot vermaelen at pi dot be
2007-04-13 9:31 ` rguenth at gcc dot gnu dot org
2007-04-17 13:05 ` patchapp at dberlin dot org
2008-04-02 12:53 ` rguenth at gcc dot gnu dot org
2008-04-02 12:55 ` rguenth at gcc dot gnu dot org
2008-04-02 12:56 ` rguenth at gcc dot gnu dot org
[not found] <20040309003513.14495.kazu@gcc.gnu.org>
2005-09-10 18:10 ` pinskia at gcc dot gnu dot org
2004-03-09 0:35 [Bug optimization/14495] New: " kazu at cs dot umass dot edu
2004-05-24 15:57 ` [Bug tree-optimization/14495] " pinskia at gcc dot gnu dot org
2005-04-24 11:52 ` pinskia at gcc dot gnu dot org
2005-05-08 18:10 ` pinskia at gcc dot gnu dot org
2005-06-03 13:55 ` 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).