Changeset 31902 in project


Ignore:
Timestamp:
11/23/14 18:05:18 (5 years ago)
Author:
sjamaan
Message:

numbers: Different approach which improves performance by a lot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/numbers/trunk/numbers-c.c

    r31901 r31902  
    4949
    5050#ifdef C_BIG_ENDIAN
     51/* This hacky way of accessing the halfwords tricks the C compiler
     52 * into using actual halfword loading instructions (at least on ppc).
     53 */
    5154typedef struct {
    52   C_uhword hi;
    53   C_uhword lo;
    54 } C_uhword_pair;
    55 
    56 /* Access the halfdigit in number x at position p (counting in halfdigits) */
    57 #define HALF_DIGIT_AT(x, p) \
    58   ((p) & 1 ? \
    59    ((C_uhword_pair *)x+((p)>>1))->hi : ((C_uhword_pair *)x+((p)>>1))->lo)
    60 
    61 /* Store a halfdigit in x at position p (counting in halfdigits) */
    62 #define STORE_HALF_DIGIT_AT(x, p, d) \
    63   ((p) & 1 ? \
    64    (*(&((C_uhword_pair *)x+((p)>>1))->hi) = (d)) : \
    65    (*(&((C_uhword_pair *)x+((p)>>1))->lo) = (d)))
     55  C_uhword hw[2];
     56} C_2_uhwords;
     57
     58#define HALF_DIGIT_AT(x,p) ((C_2_uhwords *)x+((p)>>1))->hw[!((p)&1)]
     59#define STORE_HALF_DIGIT_AT(x,p,d) ((C_2_uhwords *)x+((p)>>1))->hw[!((p)&1)]=(d)
    6660#else
    6761/* The bignum digit representation is little endian itself, too */
Note: See TracChangeset for help on using the changeset viewer.