Effectiveness of GCC optmization on bit operations

后端 未结 5 1461
暗喜
暗喜 2021-02-19 14:25

Here are two ways to set an individual bit in C on x86-64:

inline void SetBitC(long *array, int bit) {
   //Pure C version
   *array |= 1<

        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-19 14:45

    Can you post the code that you are using to do the timing? This sort of operation can be tricky to time accurately.

    In theory the two code sequences should be equally fast, so the most likely explanation (to my mind) is that something is causing your timing code to give bogus results.

提交回复
热议问题