@kas1e
Try changing to:
loopi(BPP) dst[i] = (tshift < (sizeof(t[i])*8)) ? (t[i] >> tshift) : 0;
If t[i] is signed it should be:
loopi(BPP) dst[i] = (tshift < (sizeof(t[i])*8)) ? (t[i] >> tshift) : ((t[i] < 0) ? -1 : 0);
If there is a lot of this type of code you may want to consider using macros like this (from newlib 3.1.0 libm source code):
/* Macros to avoid undefined behaviour that can arise if the amount
of a shift is exactly equal to the size of the shifted operand. */
#define SAFE_LEFT_SHIFT(op,amt) \
(((amt) < 8 * sizeof(op)) ? ((op) << (amt)) : 0)
#define SAFE_RIGHT_SHIFT(op,amt) \
(((amt) < 8 * sizeof(op)) ? ((op) >> (amt)) : 0)
Note that the SAFE_RIGHT_SHIFT needs to be modified if it's to work with signed values (where sign bit should be copied into new bits that are shifted in from the left).