After searching through the archives, I have found an interesting bit of information about DIV.G/MOD.G in the original submission thread:
> > Ruan Beihong 23 July 2008: > > > > I've seen the Loongson 2F manual carefully. The (d)div(u) is > > internally splited into one (d)div(u).g and one (d)mod(u).g. So I said > > before was wrong. The truth is that, (d)div(u).g and (d)mod(u).g are > > always faster than (d)div(u), at least the time spend on mflo/mfhi is > > saved. > > > > James Ruan > > Richard Sandiford 24 July 2008: > > OK, great. In that case, it should simply be a case of disabling > the divmod-related insns for Loongson, in addition to your patch. > (Probably stating the obvious there, sorry.) > > Richard Here's the link for part 1 of the submission thread (has the quotes from above): https://gcc.gnu.org/ml/gcc-patches/2008-07/msg01529.html and here's part 2: https://gcc.gnu.org/ml/gcc-patches/2008-11/msg00273.html If DIV.G/MOD.G are faster, according to Ruan Beihong, and also smaller than DIV (or the same size [1]), as pointed out by Maciej, then I am led to the same conclusion as Richard Sandiford: that only DIV.G/MOD.G should be generated for Loongson. I think it would still be a good idea to add a test for separated DIV.G/MOD.G, though. What are your thoughts on this ? Have I misunderstood something in the context of the submission thread ? Regards, Toma [1] I've noticed that GCC generates the same TEQ instruction twice if both DIV.G and MOD.G are needed, which makes the sequence just as big as DIV + TEQ + MFHI + MFLO; this seems unnecessary to me.