This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MIPS elimate trap-if-zero instruction if possible for divisions

On 07/03/13 11:42, Richard Sandiford wrote:
Graham Stott <> writes:
Hi Richard,

This patch attemps to elimate the TEQ instruction div DIV/MOD instructions
if possible (i.e the numerator is known to be non-zero)

I have introduced and seperated UNSPEC UNSPEC_SET_HILO_NOTRAP
which is generation by a peephole2 when the trap is known not to be required.

The peephole's work by checking for a REG_EQUAL or/REG_EQUIV on the
instruction which sets the numerator for the DIV/MOD this doesn't catch all
possible cases but does catch the common cases where ths numerator is
set set in a insn immediately preceeding the DIV/MOD.

Nice idea, but TBH, I think I'd prefer to expose the trap code at expand time
and let the rtl optimisers try to remove it.  I can't remember any correctness
reason why that wouldn't work.  I think the only reason we don't do it yet is
because (before gimple) there was a preference for keeping the division as
a unit during early rtl optimisations.
Yea, we ought to be reasonably good at detecting non-zero ranges in VRP and eliminating the trap. Doing it that way may also expose weaknesses in VRP which obviously we'd like to fix.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]