------- Comment #1 from ubizjak at gmail dot com 2010-08-07 08:33 ------- Following patch fixes this problem:
Index: gcse.c =================================================================== --- gcse.c (revision 162975) +++ gcse.c (working copy) @@ -1693,7 +1693,7 @@ compute_hash_table_work (struct hash_tab /* The next pass builds the hash table. */ FOR_BB_INSNS (current_bb, insn) - if (INSN_P (insn)) + if (INSN_P (insn) && !may_trap_p (PATTERN (insn))) hash_scan_insn (insn, table); } main: push $sp, $r6 push $sp, $r7 push $sp, $r8 push $sp, $r9 push $sp, $r10 push $sp, $r11 dec $sp, 28 lda.l $r0, a sto.l -28($fp), $r0 lda.l $r11, b xor $r6, $r6 ldi.l $r10, foo ldi.l $r8, 8 ldi.l $r7, 99 jmpa .L4 .L3: lda.l $r1, r ldo.l $r0, -28($fp) mod.l $r0, $r11 add.l $r0, $r1 add.l $r0, $r6 sta.l r, $r0 inc $r6, 1 cmp $r6, $r7 bgt .L7 .L4: jsr $r10 lda.l $r0, x cmp $r0, $r8 bne .L3 inc $r6, 1 lda.l $r1, r ldo.l $r0, -28($fp) > mod.l $r0, $r11 add.l $r0, $r1 add.l $r0, $r6 sta.l r, $r0 inc $r6, 1 cmp $r6, $r7 ble .L4 .L7: jsra abort In a general case, I guess that if it can be proved that denominator can't be zero we can still hoist mod.l out of the loop. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45223