Force compiler to not optimize side-effect-less statements

前端 未结 11 1666
执念已碎
执念已碎 2021-01-11 11:25

I was reading some old game programming books and as some of you might know, back in that day it was usually faster to do bit hacks than do things the standard way. (Convert

11条回答
  •  情歌与酒
    2021-01-11 12:07

    You just need to skip to the part where you learn something and read the published Intel CPU optimisation manual.

    These quite clearly state that casting between float and int is a really bad idea because it requires a store from the int register to memory followed by a load into a float register. These operations cause a bubble in the pipeline and waste many precious cycles.

提交回复
热议问题