Forum Rule: Always post complete source code & details to reproduce any issue!

Search:

Type: Posts; User: tni

Search: Search took 0.00 seconds.

  1. Replies
    11
    Views
    3,118

    A little benchmark (loop time in microseconds):...

    A little benchmark (loop time in microseconds):
    DivMul: 13686
    Mask: 20531
    Shift: 20533



    #include <limits>

    __attribute__((optimize("O2"))) __attribute__((always_inline)) int16_t...
  2. Replies
    11
    Views
    3,118

    Huh??? Decent compilers haven't used division...

    Huh??? Decent compilers haven't used division instructions for constants in decades.



    int testDiv4(int v) {
    return v / 4;
    }

    uint32_t testDiv4u(uint32_t v) {
    return v / 4;
  3. Replies
    11
    Views
    3,118

    You can use division / multiplication. E.g. to...

    You can use division / multiplication. E.g. to crush 2 bits: "v = v / 4 * 4".
Results 1 to 3 of 3