* Re: [patch] stmt.c: Speed/clean up expand_case - Part 2
@ 2004-10-25 23:54 Richard Kenner
0 siblings, 0 replies; 9+ messages in thread
From: Richard Kenner @ 2004-10-25 23:54 UTC (permalink / raw)
To: rth; +Cc: gcc-patches
> There could be a remote possibility of a backend generating CONST_INT
> for a tree node that is not INTEGER_CST, so I left the following
> intact.
I would be shocked if this were the case. Particularly with
gimplification.
I can't think of a case offhand, but I wouldn't be "shocked". I'd say this
was an example of "be conservative in what you generate, but liberal in
what you accept".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] stmt.c: Speed/clean up expand_case - Part 2
2004-10-25 23:39 ` Richard Henderson
@ 2004-10-25 23:56 ` Kazu Hirata
0 siblings, 0 replies; 9+ messages in thread
From: Kazu Hirata @ 2004-10-25 23:56 UTC (permalink / raw)
To: rth; +Cc: gcc-patches
Hi Richard,
> > gcc_assert (GET_CODE (index) != CONST_INT);
> >
> > as a friendly reminder to a backend. :-)
>
> Um, no, this isn't really acceptable. Just don't bother
> special casing CONST_INT here.
OK.
Kazu Hirata
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] stmt.c: Speed/clean up expand_case - Part 2
2004-10-25 23:35 ` Kazu Hirata
@ 2004-10-25 23:39 ` Richard Henderson
2004-10-25 23:56 ` Kazu Hirata
0 siblings, 1 reply; 9+ messages in thread
From: Richard Henderson @ 2004-10-25 23:39 UTC (permalink / raw)
To: Kazu Hirata; +Cc: gcc-patches
On Mon, Oct 25, 2004 at 07:17:43PM -0400, Kazu Hirata wrote:
> gcc_assert (GET_CODE (index) != CONST_INT);
>
> as a friendly reminder to a backend. :-)
Um, no, this isn't really acceptable. Just don't bother
special casing CONST_INT here.
r~
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] stmt.c: Speed/clean up expand_case - Part 2
2004-10-25 23:17 ` Richard Henderson
@ 2004-10-25 23:35 ` Kazu Hirata
2004-10-25 23:39 ` Richard Henderson
0 siblings, 1 reply; 9+ messages in thread
From: Kazu Hirata @ 2004-10-25 23:35 UTC (permalink / raw)
To: rth; +Cc: gcc-patches
Hi Richard,
> > Technically, could a backend define a __builtin_xxx and expands it to
> > a CONST_INT?
>
> Yes, it could. But I think I don't care. If optimization is on,
> it'll get cleaned up later. And the target does have the option
> of the fold_builtin target hook to make this happen earlier.
I'll submit a new patch that has both
gcc_assert (TREE_CODE (index_expr) != INTEGER_CST);
gcc_assert (GET_CODE (index) != CONST_INT);
as a friendly reminder to a backend. :-)
Kazu Hirata
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] stmt.c: Speed/clean up expand_case - Part 2
2004-10-25 22:47 ` Kazu Hirata
2004-10-25 22:50 ` Daniel Jacobowitz
@ 2004-10-25 23:17 ` Richard Henderson
2004-10-25 23:35 ` Kazu Hirata
1 sibling, 1 reply; 9+ messages in thread
From: Richard Henderson @ 2004-10-25 23:17 UTC (permalink / raw)
To: Kazu Hirata; +Cc: gcc-patches
On Mon, Oct 25, 2004 at 06:33:23PM -0400, Kazu Hirata wrote:
> Technically, could a backend define a __builtin_xxx and expands it to
> a CONST_INT?
Yes, it could. But I think I don't care. If optimization is on,
it'll get cleaned up later. And the target does have the option
of the fold_builtin target hook to make this happen earlier.
r~
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] stmt.c: Speed/clean up expand_case - Part 2
2004-10-25 22:47 ` Kazu Hirata
@ 2004-10-25 22:50 ` Daniel Jacobowitz
2004-10-25 23:17 ` Richard Henderson
1 sibling, 0 replies; 9+ messages in thread
From: Daniel Jacobowitz @ 2004-10-25 22:50 UTC (permalink / raw)
To: Kazu Hirata; +Cc: rth, gcc-patches
On Mon, Oct 25, 2004 at 06:33:23PM -0400, Kazu Hirata wrote:
> Hi Richard,
>
> > > There could be a remote possibility of a backend generating CONST_INT
> > > for a tree node that is not INTEGER_CST, so I left the following
> > > intact.
> >
> > I would be shocked if this were the case. Particularly with gimplification.
>
> Technically, could a backend define a __builtin_xxx and expands it to
> a CONST_INT?
Presumably it could also expand it to an INTEGER_CST earlier. And
should...
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] stmt.c: Speed/clean up expand_case - Part 2
2004-10-25 22:44 ` Richard Henderson
@ 2004-10-25 22:47 ` Kazu Hirata
2004-10-25 22:50 ` Daniel Jacobowitz
2004-10-25 23:17 ` Richard Henderson
0 siblings, 2 replies; 9+ messages in thread
From: Kazu Hirata @ 2004-10-25 22:47 UTC (permalink / raw)
To: rth; +Cc: gcc-patches
Hi Richard,
> > There could be a remote possibility of a backend generating CONST_INT
> > for a tree node that is not INTEGER_CST, so I left the following
> > intact.
>
> I would be shocked if this were the case. Particularly with gimplification.
Technically, could a backend define a __builtin_xxx and expands it to
a CONST_INT?
Kazu Hirata
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] stmt.c: Speed/clean up expand_case - Part 2
2004-10-25 22:17 Kazu Hirata
@ 2004-10-25 22:44 ` Richard Henderson
2004-10-25 22:47 ` Kazu Hirata
0 siblings, 1 reply; 9+ messages in thread
From: Richard Henderson @ 2004-10-25 22:44 UTC (permalink / raw)
To: Kazu Hirata; +Cc: gcc-patches
On Mon, Oct 25, 2004 at 06:11:01PM -0400, Kazu Hirata wrote:
> There could be a remote possibility of a backend generating CONST_INT
> for a tree node that is not INTEGER_CST, so I left the following
> intact.
I would be shocked if this were the case. Particularly with gimplification.
r~
^ permalink raw reply [flat|nested] 9+ messages in thread
* [patch] stmt.c: Speed/clean up expand_case - Part 2
@ 2004-10-25 22:17 Kazu Hirata
2004-10-25 22:44 ` Richard Henderson
0 siblings, 1 reply; 9+ messages in thread
From: Kazu Hirata @ 2004-10-25 22:17 UTC (permalink / raw)
To: gcc-patches
Hi,
Attached is a patch to speed/clean up expand_case.
cleanup_tree_cfg cleans up a SWITCH_EXPR with its index expression
being INTEGER_CST and replaces the SWITCH_EXPR with an unconditional
jump. This happens regardless of the optimization level.
The patch uses the above fact to simplify expand_case.
There could be a remote possibility of a backend generating CONST_INT
for a tree node that is not INTEGER_CST, so I left the following
intact.
if (GET_CODE (index) == CONST_INT)
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2004-10-25 Kazu Hirata <kazu@cs.umass.edu>
* stmt.c (expand_case): Remove code to handle constant
index_expr.
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.402
diff -u -p -r1.402 stmt.c
--- stmt.c 24 Oct 2004 00:46:10 -0000 1.402
+++ stmt.c 25 Oct 2004 14:45:09 -0000
@@ -2355,6 +2355,10 @@ expand_case (tree exp)
{
tree elt;
+ /* cleanup_tree_cfg removes all SWITCH_EXPR with their index
+ expressions being INTEGER_CST. */
+ gcc_assert (TREE_CODE (index_expr) != INTEGER_CST);
+
/* The default case is at the end of TREE_VEC. */
elt = TREE_VEC_ELT (vec, TREE_VEC_LENGTH (vec) - 1);
gcc_assert (!CASE_HIGH (elt));
@@ -2498,19 +2502,15 @@ expand_case (tree exp)
if (MEM_P (index))
index = copy_to_reg (index);
- if (GET_CODE (index) == CONST_INT
- || TREE_CODE (index_expr) == INTEGER_CST)
+ if (GET_CODE (index) == CONST_INT)
{
/* Make a tree node with the proper constant value
if we don't already have one. */
- if (TREE_CODE (index_expr) != INTEGER_CST)
- {
- index_expr
- = build_int_cst_wide (NULL_TREE, INTVAL (index),
- unsignedp || INTVAL (index) >= 0
- ? 0 : -1);
- index_expr = convert (index_type, index_expr);
- }
+ index_expr
+ = build_int_cst_wide (NULL_TREE, INTVAL (index),
+ unsignedp || INTVAL (index) >= 0
+ ? 0 : -1);
+ index_expr = convert (index_type, index_expr);
/* For constant index expressions we need only
issue an unconditional branch to the appropriate
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-10-25 23:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-25 23:54 [patch] stmt.c: Speed/clean up expand_case - Part 2 Richard Kenner
-- strict thread matches above, loose matches on Subject: below --
2004-10-25 22:17 Kazu Hirata
2004-10-25 22:44 ` Richard Henderson
2004-10-25 22:47 ` Kazu Hirata
2004-10-25 22:50 ` Daniel Jacobowitz
2004-10-25 23:17 ` Richard Henderson
2004-10-25 23:35 ` Kazu Hirata
2004-10-25 23:39 ` Richard Henderson
2004-10-25 23:56 ` Kazu Hirata
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).