From mboxrd@z Thu Jan 1 00:00:00 1970 From: pmw@uk.research.att.com (Paul Webster) To: gcc-help@gcc.gnu.org Subject: CASESI: GCC is optimising away my cases Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: <199912141720.RAA11121@rocoto> X-SW-Source: 1999-12n/msg00218.html Message-ID: <19991231222400.e1lwVMfFIczSHEGQ6az8YeyWeN0uWnL0d_zXZ4V-nf4@z> 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. ==============================================================================