From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jim Wilson To: Kamil Iskra Cc: egcs@cygnus.com Subject: Re: Loop optimizer misses simple optimisation? Date: Wed, 29 Apr 1998 15:21:00 -0000 Message-id: <199804292128.OAA01108@rtl.cygnus.com> References: X-SW-Source: 1998-04/msg01166.html I checked, and Mike Meissner's comment is correct. The problem here is that the m68k divide instruction computes two values (quotient and remainder), giving us: (insn 83 33 84 (parallel[ (set (reg:SI 34) (udiv:SI (const_int 4194304) (reg/v:SI 29))) (set (reg:SI 35) (umod:SI (const_int 4194304) (reg/v:SI 29))) ] ) -1 (nil) (nil)) In scan_loop in loop.c, the code that recognizes loop invariant instructions does this: if (GET_CODE (p) == INSN && (set = single_set (p)) && GET_CODE (SET_DEST (set)) == REG && ! may_not_optimize[REGNO (SET_DEST (set))]) The single_set checks means that insns that compute two values are never considered for loop-invariant-code-motion, hence we won't move a m68k divide out of a loop. We would need to generalize the LICM code to handle insns with multiple sets to fix this. Jim