2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

floatとdouble, intとlong

Last updated at Posted at 2018-12-06

64bit整数型が遅い理由
https://teratail.com/questions/105014

という記事を拝見した。

C/C++で記述する際に、型を何にするか、
型の変換を途中でするかどうかを検討。

検討事項1

from a_saitoh

・足し算引き算はintが最速。他のビット長はintと同じか遅い。
・かけ算はintが最速かどうかはCPU次第。
・整数の割り算はビット長が長いほど手間がかかる

検討事項2

from asm
「インテル® 64 アーキテクチャーおよび IA-32 アーキテクチャー最適化リファレンス・マニュアル(の参考訳)によると

アセンブリー/コンパイラー・コーディング規則 63 (影響 H、一般性 M): 64 ビット・モードでは、64 ビット・データや追加レジスターへのアクセスに 64 ビット版の命令が必要な場合を除き、32 ビット版の命令を使うことでコードサイズを削減します。」

https://software.intel.com/en-us/download/intel-64-and-ia-32-architectures-optimization-reference-manual
"page 10-1
Assembly/Compiler Coding Rule 63. (H impact, M generality) Use the 32-bit versions of instructions in 64-bit mode to reduce code size unless the 64-bit version is necessary to access 64-bit data or additional registers."

Intel Assemble/Compiler Coding Rule 英日対訳比較検討(まだ途中まで)
https://qiita.com/kaizen_nagoya/items/eb04b998224047a32ef1

検討事項3 alignment

型の大きさがちがうと、alignmentをかんがえておかないと、
読み書きが遅くなる可能性がある。

検討事項4 cache

キャッシュをOn/OFFするかどうか、
一次キャッシュ、二次キャッシュなどの設定状況。

検討事項5 型変換

整数型、浮動小数点型との間の変換を含める。

文書履歴

ver. 0.10 初稿 20181206午前
ver. 0.11 追記 20181206午後

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?