public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* CASESI: GCC is  optimising away my cases
@ 1999-12-14  9:20 Paul Webster
  1999-12-14  9:51 ` Jeffrey A Law
  1999-12-31 22:24 ` Paul Webster
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Webster @ 1999-12-14  9:20 UTC (permalink / raw)
  To: gcc-help

Hi all,

I'm trying to port the GCC compiler to a new machine description. I've got the 
basics working and am now trying to optimise case statements when using a 
dispatch table.

I've created a `casesi' pattern which outputs code for jumping via the table.
This produces the expected code. However, when I run the compiler with any
optimisation enabled, it removes the blocks of code referred to in the dispatch
table.

What it looks like is happening is that the jump optimisation cannot find a
jump which refers to the routines (as they are done indirectly via the dispatch
table), so it decides it can happily remove the code as it can never be called.
The label entries are still in the dispatch table, but are no longer defined.
If I have a default case, this is still maintained, as my bounds-checking branch
refers to this.

I've looked through the supplied machine descriptions and headers and cannot
see anything obvious that I am missing. What I think I need to do is mark the
case routines as being used by the main body of the code. I've seen comments
to the effect that this can be done by generating dummy jumps to each of the
cases, but I cannot find a clear example of how I can do this. If I remove the
`casesi' pattern and define a `tablejump' pattern the cases are not optimised
away, but the jump code is then non-optimal!

Could anyone offer any suggestions on the best way I can stop GCC optimising
this code away!

Thanks in advance,

    Paul


==============================================================================
                          AT&T Laboratories Cambridge
------------------------------------------------------------------------------
    Dr. Paul Webster, 24a Trumpington Street, Cambridge, CB2 1QA, England.
==============================================================================

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: CASESI: GCC is optimising away my cases
  1999-12-14  9:20 CASESI: GCC is optimising away my cases Paul Webster
@ 1999-12-14  9:51 ` Jeffrey A Law
  1999-12-31 22:24   ` Jeffrey A Law
  1999-12-31 22:24 ` Paul Webster
  1 sibling, 1 reply; 4+ messages in thread
From: Jeffrey A Law @ 1999-12-14  9:51 UTC (permalink / raw)
  To: Paul Webster; +Cc: gcc-help

  In message < 199912141720.RAA11121@rocoto >you write:
  > 
  > I've created a `casesi' pattern which outputs code for jumping via the
  > table.  This produces the expected code. However, when I run the compiler
  > with any optimisation enabled, it removes the blocks of code referred to
  > in the dispatch table.
  > 
  > What it looks like is happening is that the jump optimisation cannot find a
  > jump which refers to the routines (as they are done indirectly via the
  > dispatch table),
This is your problem.  You need to show at the RTL level that each label
is used.

Your casesi pattern should be followed by an ADDR_VEC or ADDR_DIFF_VEC insn
which should contain a reference to each target label.  Why is that not
happening?

jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* CASESI: GCC is  optimising away my cases
  1999-12-14  9:20 CASESI: GCC is optimising away my cases Paul Webster
  1999-12-14  9:51 ` Jeffrey A Law
@ 1999-12-31 22:24 ` Paul Webster
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Webster @ 1999-12-31 22:24 UTC (permalink / raw)
  To: gcc-help

Hi all,

I'm trying to port the GCC compiler to a new machine description. I've got the 
basics working and am now trying to optimise case statements when using a 
dispatch table.

I've created a `casesi' pattern which outputs code for jumping via the table.
This produces the expected code. However, when I run the compiler with any
optimisation enabled, it removes the blocks of code referred to in the dispatch
table.

What it looks like is happening is that the jump optimisation cannot find a
jump which refers to the routines (as they are done indirectly via the dispatch
table), so it decides it can happily remove the code as it can never be called.
The label entries are still in the dispatch table, but are no longer defined.
If I have a default case, this is still maintained, as my bounds-checking branch
refers to this.

I've looked through the supplied machine descriptions and headers and cannot
see anything obvious that I am missing. What I think I need to do is mark the
case routines as being used by the main body of the code. I've seen comments
to the effect that this can be done by generating dummy jumps to each of the
cases, but I cannot find a clear example of how I can do this. If I remove the
`casesi' pattern and define a `tablejump' pattern the cases are not optimised
away, but the jump code is then non-optimal!

Could anyone offer any suggestions on the best way I can stop GCC optimising
this code away!

Thanks in advance,

    Paul


==============================================================================
                          AT&T Laboratories Cambridge
------------------------------------------------------------------------------
    Dr. Paul Webster, 24a Trumpington Street, Cambridge, CB2 1QA, England.
==============================================================================

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: CASESI: GCC is optimising away my cases
  1999-12-14  9:51 ` Jeffrey A Law
@ 1999-12-31 22:24   ` Jeffrey A Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeffrey A Law @ 1999-12-31 22:24 UTC (permalink / raw)
  To: Paul Webster; +Cc: gcc-help

  In message < 199912141720.RAA11121@rocoto >you write:
  > 
  > I've created a `casesi' pattern which outputs code for jumping via the
  > table.  This produces the expected code. However, when I run the compiler
  > with any optimisation enabled, it removes the blocks of code referred to
  > in the dispatch table.
  > 
  > What it looks like is happening is that the jump optimisation cannot find a
  > jump which refers to the routines (as they are done indirectly via the
  > dispatch table),
This is your problem.  You need to show at the RTL level that each label
is used.

Your casesi pattern should be followed by an ADDR_VEC or ADDR_DIFF_VEC insn
which should contain a reference to each target label.  Why is that not
happening?

jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-12-31 22:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-14  9:20 CASESI: GCC is optimising away my cases Paul Webster
1999-12-14  9:51 ` Jeffrey A Law
1999-12-31 22:24   ` Jeffrey A Law
1999-12-31 22:24 ` Paul Webster

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).