Changeset afaa70 in git


Ignore:
Timestamp:
Nov 10, 2017, 10:20:37 AM (6 years ago)
Author:
Andreas Steenpass <steenpass@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
d4659730f5d051bbee5937a7f2b59acecc3f7aa0
Parents:
971a80779ac3cac292826e9392ea037d28a0ccd4
git-author:
Andreas Steenpass <steenpass@mathematik.uni-kl.de>2017-11-10 10:20:37+01:00
git-committer:
Andreas Steenpass <steenpass@mathematik.uni-kl.de>2017-12-15 12:17:08+01:00
Message:
chg: add more likely/unlikely
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/GBEngine/syz4.cc

    r971a80 rafaa70  
    1616
    1717#ifdef __GNUC__
    18 #define likely(X)   (__builtin_expect(X, 1))
    19 #define unlikely(X) (__builtin_expect(X, 0))
     18#define likely(X)   (__builtin_expect(!!(X), 1))
     19#define unlikely(X) (__builtin_expect(!!(X), 0))
    2020#else
    2121#define likely(X)   (X)
     
    5454    }
    5555    for (int j = R->N; j > 0; j--) {
    56         if (variables[j-1] && p_GetExp(m, j, R) > 0) {
     56        if (unlikely(variables[j-1] && p_GetExp(m, j, R) > 0)) {
    5757            return true;
    5858        }
     
    8888    const ring r = currRing;
    8989    lts_hash::const_iterator itr = hash_previous_module->find(p_GetComp(t, r));
    90     if (itr == hash_previous_module->end()) {
     90    if (unlikely(itr == hash_previous_module->end())) {
    9191        return NULL;
    9292    }
     
    9898    const unsigned long q_not_sev = ~p_GetShortExpVector(q, r);
    9999    for( ; itr_curr != itr_end; ++itr_curr) {
    100         if (itr_curr->sev & q_not_sev
     100        if (likely(itr_curr->sev & q_not_sev)
    101101                || unlikely(!(_p_LmDivisibleByNoComp(itr_curr->lt, q, r)))) {
    102102            continue;
     
    137137    const poly t = traverse_tail(s, c, previous_module, variables,
    138138            hash_previous_module);
    139     if (t != NULL) {
     139    if (unlikely(t != NULL)) {
    140140        s = p_Add_q(s, t, r);
    141141    }
     
    148148{
    149149    const poly tail = previous_module->m[comp]->next;
    150     if (tail == NULL || !check_variables(variables, multiplier)) {
     150    if (unlikely(tail == NULL) || !check_variables(variables, multiplier)) {
    151151        return NULL;
    152152    }
     
    213213        const poly multiplier)
    214214{
    215     if(itr->second == NULL) {
     215    if (likely(itr->second == NULL)) {
    216216        return NULL;
    217217    }
    218218    const ring r = currRing;
    219219    poly p = p_Copy(itr->second, r);
    220     if (!n_Equal(pGetCoeff(multiplier), pGetCoeff(itr->first), r)) {
     220    if (likely(!n_Equal(pGetCoeff(multiplier), pGetCoeff(itr->first), r))) {
    221221        number n = n_Div(pGetCoeff(multiplier), pGetCoeff(itr->first), r);
    222222        p = p_Mult_nn(p, n, r);
     
    232232    cache_term *T = &(Cache[comp]);
    233233    cache_term::iterator itr = T->find(multiplier);
    234     if (itr != T->end()) {
     234    if (likely(itr != T->end())) {
    235235        return get_from_cache_term(itr, multiplier);
    236236    }
     
    503503        poly p = res[1]->m[i];
    504504        while (p != NULL) {
    505             if (pGetComp(p) == comp) {
     505            if (unlikely(pGetComp(p) == comp)) {
    506506                n_InpMult(pGetCoeff(p), coef_inv, r->cf);
    507507            }
Note: See TracChangeset for help on using the changeset viewer.