Hi Richard,Thanks for the review. Attached is a revised patch which addresses the issues that you raised:
+/* A special mode used to distinguish the Lcc branch instruction+ from the Bcc branch instruction. */ +CC_MODE (CC_LCC);Why not just use an unspec on the lcc insn.
I should have done. The CC_LCC mode was a holdover from when I was trying to get the doloop patterns to work. The doloop pattern recognizer does not accept UNSPECs, so I had to use a unique CC mode instead. The revised patch uses an UNSPEC.
+ /* What we're doing here is looking for a conditional branch which + branches backwards without crossing any non-debug labels. I.e. + the loop has to enter from the top. */Ug. Surely we can re-use the existing loop detection code to find the inner-most loops.
We can, but it is a lot more complicated than just performing a simple scan. Still I have tried my best to follow up on this. One thing that does worry me however is that I encountered a segmentation fault whilst trying to free the loop data. (See a comment in the patch for more details). I tried to follow the example of other passes that use the loop information, but I must have gotten something wrong. Any pointers on how to fix this are greatly appreciated.
Cheers Nick gcc/ChangeLog 2011-03-08 Nick Clifton <ni...@redhat.com> * config/mn10300/mn10300.c: Include cfgloop.h. (DUMP): New macro. (mn10300_insert_setlb_lcc): New function. Inserts a SETLB and a Lcc or a FLcc insn into the instruction stream. (mn10300_block_contains_call): New function. Returns true if the given basic block contains a CALL insn. (mn10300_loop_contains_call_insn): New function. Returns true if the given loop contains a CALL insn. (mn10300_scan_for_setlb_lcc): New function. Finds opportunities to use the SETLB and Lcc or FLcc insns. (mn10300_reorg): Invoke mn10300_scan_for_setlb_lcc. (TARGET_FLAGS): Add MASK_ALLOW_SETLB. * config/mn10300/mn10300.opt (msetlb): New option. Used to disable the SETLB optimization. * config/mn10300/mn10300.h (TARGET_CPU_CPP_BUILTINS): Add __SETLB__ or __NO_SETLB__. * config/mn10300/mn10300.md (UNSPEC_SETLB): New constant. (cmpsi): Make visible. (setlb): New pattern. (Lcc): New pattern. (FLcc): New pattern. * doc/invoke.texi: Document -mno-setlb option.
mn10300.setlb.patch.3
Description: Unix manual page