推 VictorTom:所以才會說未最佳化的話, i++可能效能略差, 因為多一個 08/24 12:35
→ VictorTom:mov與暫用一個temp register....@_@" 08/24 12:35
推 ledia:primitive type, compiler 不至於會多用一個 register 吧 08/24 13:30
推 sjgau:我是習慣使用 i++, 既然樓上的都這麼說,我來 bench 看看 08/24 13:36
推 VictorTom:請教l大, 為什麼primitive type就不用多個 reg 呢?_? 08/24 13:38
→ VictorTom:回s大, 個人覺得disasm比較直接, 因為通常i++/++i的 08/24 13:38
→ VictorTom:overhead遠小於其他code吧?? 光是compare就不知道比 08/24 13:39
→ VictorTom:它慢多少了不是嗎?_? 08/24 13:39
→ VictorTom:啊, 忘了迴圈也可以不要終止條件無窮跑下去....XD 08/24 13:40
推 ledia:我猜測 compiler 會知道 i++ 要不要 keep 那個 i 吧 08/24 17:09
→ ledia:至少我 gcc -S 看起來是沒差的, 其它 compiler 就不知了 08/24 17:10
推 VictorTom:compiler知道要不要keep, 就是有一定程度opt啦@_@" 08/24 17:33
→ VictorTom:小弟本來是想說直接看 i++ 與 ++i 的組語各是怎翻的XD 08/24 17:33
推 ledia:沒加 optimize 參數喔, 我覺得是免費送的 XD 08/25 02:17
推 holymars:對primitive type根本沒差.. 08/25 18:44