http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49880
Oleg Endo <olegendo at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |olegendo at gcc dot gnu.org --- Comment #3 from Oleg Endo <olegendo at gcc dot gnu.org> 2013-03-11 20:29:57 UTC --- (In reply to comment #1) > I've confirmed that trunk and all released compilers fail with > -m4 -mdiv=call-div1. I'm testing the patch below. > > * config/sh/sh.md (udivsi3_i1): Enable for TARGET_DIVIDE_CALL_DIV1. > (divsi3_i1): Likewise. > > --- ORIG/trunk/gcc/config/sh/sh.md 2011-07-20 09:27:11.000000000 +0900 > +++ trunk/gcc/config/sh/sh.md 2011-07-28 06:49:41.000000000 +0900 > @@ -1609,7 +1609,7 @@ > (clobber (reg:SI PR_REG)) > (clobber (reg:SI R4_REG)) > (use (match_operand:SI 1 "arith_reg_operand" "r"))] > - "TARGET_SH1 && ! TARGET_SH4" > + "TARGET_SH1 && (! TARGET_SH4 || TARGET_DIVIDE_CALL_DIV1)" > "jsr @%1%#" > [(set_attr "type" "sfunc") > (set_attr "needs_delay_slot" "yes")]) > @@ -1815,7 +1815,7 @@ > (clobber (reg:SI R2_REG)) > (clobber (reg:SI R3_REG)) > (use (match_operand:SI 1 "arith_reg_operand" "r"))] > - "TARGET_SH1 && ! TARGET_SH4" > + "TARGET_SH1 && (! TARGET_SH4 || TARGET_DIVIDE_CALL_DIV1)" > "jsr @%1%#" > [(set_attr "type" "sfunc") > (set_attr "needs_delay_slot" "yes")]) I think the conditions "TARGET_SH1 && (! TARGET_SH4 || TARGET_DIVIDE_CALL_DIV1)" can be simplified to "TARGET_SH1 && TARGET_DIVIDE_CALL_DIV1" in this case. The division strategy is selected in sh_option_override, which already does all the checks, so there should be no need to check for TARGET_SH4. Seeing the "! TARGET_SH4" in the conditions is a bit confusing, because -mdiv=call-div1 is available on all SH variants except SHmedia. I've tried the simplified conditions and it works as expected. I'll submit a patch that also adds a some test cases for for -mdiv option.