inlined mpn_add_n with constant size?

Vincent Lefevre vincent at vinc17.org
Wed Mar 19 17:36:12 CET 2008


Hi all,

I have code using GMP that calls mpn_add_n only, and always with
a constant size (in general, <= 9). Is there a way to get inlined
code optimized for the given size?

Here's an example of code:

      mpn_add_n((mp_limb_t *) a0_0, (mp_limb_t *) a0_0,
                (mp_limb_t *) a0_1 + 1, 2);
      mpn_add_n((mp_limb_t *) a0_1, (mp_limb_t *) a0_1,
                (mp_limb_t *) a0_2 + 0, 3);
      mpn_add_n((mp_limb_t *) a0_2, (mp_limb_t *) a0_2,
                (mp_limb_t *) a0_3 + 1, 3);
      mpn_add_n((mp_limb_t *) a0_3, (mp_limb_t *) a0_3,
                (mp_limb_t *) a0_4 + 1, 4);
      mpn_add_n((mp_limb_t *) a0_4, (mp_limb_t *) a0_4,
                (mp_limb_t *) a0_5 + 0, 5);
      mpn_add_n((mp_limb_t *) a0_5, (mp_limb_t *) a0_5,
                (mp_limb_t *) a0_6 + 0, 5);
      mpn_add_n((mp_limb_t *) a1_0, (mp_limb_t *) a1_0,
                (mp_limb_t *) a1_1 + 1, 2);
      mpn_add_n((mp_limb_t *) a1_1, (mp_limb_t *) a1_1,
                (mp_limb_t *) a1_2 + 0, 3);
      mpn_add_n((mp_limb_t *) a1_2, (mp_limb_t *) a1_2,
                (mp_limb_t *) a1_3 + 1, 3);
      mpn_add_n((mp_limb_t *) a1_3, (mp_limb_t *) a1_3,
                (mp_limb_t *) a1_4 + 1, 4);
      mpn_add_n((mp_limb_t *) a1_4, (mp_limb_t *) a1_4,
                (mp_limb_t *) a1_5 + 0, 5);
      mpn_add_n((mp_limb_t *) a2_0, (mp_limb_t *) a2_0,
                (mp_limb_t *) a2_1 + 1, 2);
      mpn_add_n((mp_limb_t *) a2_1, (mp_limb_t *) a2_1,
                (mp_limb_t *) a2_2 + 0, 3);
      mpn_add_n((mp_limb_t *) a2_2, (mp_limb_t *) a2_2,
                (mp_limb_t *) a2_3 + 1, 3);
      mpn_add_n((mp_limb_t *) a2_3, (mp_limb_t *) a2_3,
                (mp_limb_t *) a2_4 + 1, 4);

Regards,

-- 
Vincent Lefèvre <vincent at vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)


More information about the gmp-discuss mailing list