mips16: div/mod by zero patch

Jeffrey A Law law@unknown
Tue Jan 20 09:01:00 GMT 1998


  In message < m0xsbHR-0006vBC@cetus.cygnus.com >you write:
  > 
  > In the mips backend, for non-optimized -mips16 code, for a div
  > or mod by the constant zero (or something that folds to the
  > constant zero), the compiler is generating something like
  > 
  >     div $0,$4,0
  > 
  > which is not a valid mips16 instruction, and you get assembler
  > errors.  
  > 
  > (Of course div or mod by zero will fail, but it should not
  > do so until runtime, if the expression is exectuted.  Ironically
  > this does not fail for other constants, because the compiler
  > generally generates a sequence of shifts and adds for the division.)
  > 
  > This patch fixes this by changing the non-optimized div and mod
  > insns to force the last arg into a register if -mips16.
  > 
  > 	mips/mips.md (divsi3,divdi3,modsi3,moddi3,udivsi3,udivdi3,
  > 	umodsi3,umoddi3): Handle mips16 div/mod by a constant.
Looks reasonable to me.  I think you should install this patch.

jeff



More information about the Gcc mailing list