Hello Zoran, I may be wrong, but what you are trying to do is very similar to what's in fold-const.c optimize_bit_field_compare().
There was a discussion in April 2012 on this thread: "Continue strict-volatile-bitfields fixes" http://gcc.gnu.org/ml/gcc-patches/2012-04/msg01094.html The result was that this optimization seems to break other possible optimizations later on, when -fstrict-volatile-bitfields was enabled on the SH target. Even when the bit fields are NOT volatile. (Of course you should not touch volatile bit fields at all) And this was added to optimize_bit_field_compare as a result: /* In the strict volatile bitfields case, doing code changes here may prevent other optimizations, in particular in a SLOW_BYTE_ACCESS setting. */ if (flag_strict_volatile_bitfields> 0) return 0; Regards Bernd.