質問編集履歴
7
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -234,4 +234,5 @@
|
|
234
234
|
これは、変数のサイズがCPUのレジスタ長と一致していれば相性が良いということなんでしょうかね??
|
235
235
|
|
236
236
|
> C++だと、cstdintに「Nbitの精度を保証して、かつ処理効率が最速になる型」というものが定義されている
|
237
|
+
|
237
238
|
単に、機械語だけだとすると、上記のような型を定義する必要はありませんよね??
|
6
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -231,4 +231,7 @@
|
|
231
231
|
> CPUには得意なデータ型というものがあります。
|
232
232
|
|
233
233
|
とのことです。
|
234
|
-
これは、変数のサイズがCPUのレジスタ長と一致していれば相性が良いということなんでしょうかね??
|
234
|
+
これは、変数のサイズがCPUのレジスタ長と一致していれば相性が良いということなんでしょうかね??
|
235
|
+
|
236
|
+
> C++だと、cstdintに「Nbitの精度を保証して、かつ処理効率が最速になる型」というものが定義されている
|
237
|
+
単に、機械語だけだとすると、上記のような型を定義する必要はありませんよね??
|
5
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -224,4 +224,11 @@
|
|
224
224
|
同じようなことを議論しているサイトを見つけました。
|
225
225
|
[64bit化による処理速度の影響 ](https://social.msdn.microsoft.com/Forums/ja-JP/64914bbd-cb0c-4a90-9c99-375a44cf9137/64bit?forum=windowsgeneraldevelopmentissuesja)
|
226
226
|
[整数の型にint型ばかりを使うのは何故でしょうか。](https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q126888327)
|
227
|
-
[C言語の型による処理速度の違い](https://oshiete.goo.ne.jp/qa/2168550.html)
|
227
|
+
[C言語の型による処理速度の違い](https://oshiete.goo.ne.jp/qa/2168550.html)
|
228
|
+
[short と int の計算速度](http://dixq.net/forum/viewtopic.php?f=3&t=14756)
|
229
|
+
[最も速い数値型](http://cpp.aquariuscode.com/int_fast_t)
|
230
|
+
|
231
|
+
> CPUには得意なデータ型というものがあります。
|
232
|
+
|
233
|
+
とのことです。
|
234
|
+
これは、変数のサイズがCPUのレジスタ長と一致していれば相性が良いということなんでしょうかね??
|
4
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -218,4 +218,10 @@
|
|
218
218
|
845: c3 retq
|
219
219
|
846: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
|
220
220
|
84d: 00 00 00
|
221
|
-
```
|
221
|
+
```
|
222
|
+
|
223
|
+
[追記3]
|
224
|
+
同じようなことを議論しているサイトを見つけました。
|
225
|
+
[64bit化による処理速度の影響 ](https://social.msdn.microsoft.com/Forums/ja-JP/64914bbd-cb0c-4a90-9c99-375a44cf9137/64bit?forum=windowsgeneraldevelopmentissuesja)
|
226
|
+
[整数の型にint型ばかりを使うのは何故でしょうか。](https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q126888327)
|
227
|
+
[C言語の型による処理速度の違い](https://oshiete.goo.ne.jp/qa/2168550.html)
|
3
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -91,4 +91,131 @@
|
|
91
91
|
書くのを忘れていました。最適化は行っていません。
|
92
92
|
今回の場合、最適化を行うと実験の意味がなくなってしまいます。
|
93
93
|
|
94
|
+
Intel Core i7-4650U @ 4x 3.3GHz
|
94
|
-
|
95
|
+
Linux 64bit環境
|
96
|
+
|
97
|
+
[追記2]
|
98
|
+
objdump -d による結果を載せます。64bitコンパイルの方です。
|
99
|
+
main()を一応全部載せておきます。
|
100
|
+
|
101
|
+
```ここに言語を入力
|
102
|
+
000000000000068a <main>:
|
103
|
+
68a: 55 push %rbp
|
104
|
+
68b: 48 89 e5 mov %rsp,%rbp
|
105
|
+
68e: 48 83 ec 50 sub $0x50,%rsp
|
106
|
+
692: c6 45 f7 7b movb $0x7b,-0x9(%rbp)
|
107
|
+
696: c6 45 f6 2d movb $0x2d,-0xa(%rbp)
|
108
|
+
69a: e8 b1 fe ff ff callq 550 <clock@plt>
|
109
|
+
69f: 89 45 f0 mov %eax,-0x10(%rbp)
|
110
|
+
6a2: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp)
|
111
|
+
6a9: 00
|
112
|
+
6aa: eb 13 jmp 6bf <main+0x35>
|
113
|
+
6ac: 0f be 45 f7 movsbl -0x9(%rbp),%eax
|
114
|
+
6b0: 0f be 4d f6 movsbl -0xa(%rbp),%ecx
|
115
|
+
6b4: 99 cltd
|
116
|
+
6b5: f7 f9 idiv %ecx
|
117
|
+
6b7: 88 45 b5 mov %al,-0x4b(%rbp)
|
118
|
+
6ba: 48 83 45 f8 01 addq $0x1,-0x8(%rbp)
|
119
|
+
6bf: 48 81 7d f8 00 e1 f5 cmpq $0x5f5e100,-0x8(%rbp)
|
120
|
+
6c6: 05
|
121
|
+
6c7: 7e e3 jle 6ac <main+0x22>
|
122
|
+
6c9: e8 82 fe ff ff callq 550 <clock@plt>
|
123
|
+
6ce: 89 45 ec mov %eax,-0x14(%rbp)
|
124
|
+
6d1: 8b 45 ec mov -0x14(%rbp),%eax
|
125
|
+
6d4: 2b 45 f0 sub -0x10(%rbp),%eax
|
126
|
+
6d7: f2 0f 2a c0 cvtsi2sd %eax,%xmm0
|
127
|
+
6db: f2 0f 10 0d 95 02 00 movsd 0x295(%rip),%xmm1 # 978 <_IO_stdin_used+0xa8>
|
128
|
+
6e2: 00
|
129
|
+
6e3: f2 0f 5e c1 divsd %xmm1,%xmm0
|
130
|
+
6e7: 48 8d 3d ea 01 00 00 lea 0x1ea(%rip),%rdi # 8d8 <_IO_stdin_used+0x8>
|
131
|
+
6ee: b8 01 00 00 00 mov $0x1,%eax
|
132
|
+
6f3: e8 68 fe ff ff callq 560 <printf@plt>
|
133
|
+
6f8: 66 c7 45 ea 7b 00 movw $0x7b,-0x16(%rbp)
|
134
|
+
6fe: 66 c7 45 e8 2d 00 movw $0x2d,-0x18(%rbp)
|
135
|
+
704: e8 47 fe ff ff callq 550 <clock@plt>
|
136
|
+
709: 89 45 f0 mov %eax,-0x10(%rbp)
|
137
|
+
70c: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp)
|
138
|
+
713: 00
|
139
|
+
714: eb 14 jmp 72a <main+0xa0>
|
140
|
+
716: 0f bf 45 ea movswl -0x16(%rbp),%eax
|
141
|
+
71a: 0f bf 75 e8 movswl -0x18(%rbp),%esi
|
142
|
+
71e: 99 cltd
|
143
|
+
71f: f7 fe idiv %esi
|
144
|
+
721: 66 89 45 b6 mov %ax,-0x4a(%rbp)
|
145
|
+
725: 48 83 45 f8 01 addq $0x1,-0x8(%rbp)
|
146
|
+
72a: 48 81 7d f8 00 e1 f5 cmpq $0x5f5e100,-0x8(%rbp)
|
147
|
+
731: 05
|
148
|
+
732: 7e e2 jle 716 <main+0x8c>
|
149
|
+
734: e8 17 fe ff ff callq 550 <clock@plt>
|
150
|
+
739: 89 45 ec mov %eax,-0x14(%rbp)
|
151
|
+
73c: 8b 45 ec mov -0x14(%rbp),%eax
|
152
|
+
73f: 2b 45 f0 sub -0x10(%rbp),%eax
|
153
|
+
742: f2 0f 2a c0 cvtsi2sd %eax,%xmm0
|
154
|
+
746: f2 0f 10 0d 2a 02 00 movsd 0x22a(%rip),%xmm1 # 978 <_IO_stdin_used+0xa8>
|
155
|
+
74d: 00
|
156
|
+
74e: f2 0f 5e c1 divsd %xmm1,%xmm0
|
157
|
+
752: 48 8d 3d a7 01 00 00 lea 0x1a7(%rip),%rdi # 900 <_IO_stdin_used+0x30>
|
158
|
+
759: b8 01 00 00 00 mov $0x1,%eax
|
159
|
+
75e: e8 fd fd ff ff callq 560 <printf@plt>
|
160
|
+
763: 48 c7 45 e0 7b 00 00 movq $0x7b,-0x20(%rbp)
|
161
|
+
76a: 00
|
162
|
+
76b: 48 c7 45 d8 2d 00 00 movq $0x2d,-0x28(%rbp)
|
163
|
+
772: 00
|
164
|
+
773: e8 d8 fd ff ff callq 550 <clock@plt>
|
165
|
+
778: 89 45 f0 mov %eax,-0x10(%rbp)
|
166
|
+
77b: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp)
|
167
|
+
782: 00
|
168
|
+
783: eb 13 jmp 798 <main+0x10e>
|
169
|
+
785: 48 8b 45 e0 mov -0x20(%rbp),%rax
|
170
|
+
789: 48 99 cqto
|
171
|
+
78b: 48 f7 7d d8 idivq -0x28(%rbp)
|
172
|
+
78f: 48 89 45 b8 mov %rax,-0x48(%rbp)
|
173
|
+
793: 48 83 45 f8 01 addq $0x1,-0x8(%rbp)
|
174
|
+
798: 48 81 7d f8 00 e1 f5 cmpq $0x5f5e100,-0x8(%rbp)
|
175
|
+
79f: 05
|
176
|
+
7a0: 7e e3 jle 785 <main+0xfb>
|
177
|
+
7a2: e8 a9 fd ff ff callq 550 <clock@plt>
|
178
|
+
7a7: 89 45 ec mov %eax,-0x14(%rbp)
|
179
|
+
7aa: 8b 45 ec mov -0x14(%rbp),%eax
|
180
|
+
7ad: 2b 45 f0 sub -0x10(%rbp),%eax
|
181
|
+
7b0: f2 0f 2a c0 cvtsi2sd %eax,%xmm0
|
182
|
+
7b4: f2 0f 10 0d bc 01 00 movsd 0x1bc(%rip),%xmm1 # 978 <_IO_stdin_used+0xa8>
|
183
|
+
7bb: 00
|
184
|
+
7bc: f2 0f 5e c1 divsd %xmm1,%xmm0
|
185
|
+
7c0: 48 8d 3d 61 01 00 00 lea 0x161(%rip),%rdi # 928 <_IO_stdin_used+0x58>
|
186
|
+
7c7: b8 01 00 00 00 mov $0x1,%eax
|
187
|
+
7cc: e8 8f fd ff ff callq 560 <printf@plt>
|
188
|
+
7d1: 48 c7 45 d0 7b 00 00 movq $0x7b,-0x30(%rbp)
|
189
|
+
7d8: 00
|
190
|
+
7d9: 48 c7 45 c8 2d 00 00 movq $0x2d,-0x38(%rbp)
|
191
|
+
7e0: 00
|
192
|
+
7e1: e8 6a fd ff ff callq 550 <clock@plt>
|
193
|
+
7e6: 89 45 f0 mov %eax,-0x10(%rbp)
|
194
|
+
7e9: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp)
|
195
|
+
7f0: 00
|
196
|
+
7f1: eb 13 jmp 806 <main+0x17c>
|
197
|
+
7f3: 48 8b 45 d0 mov -0x30(%rbp),%rax
|
198
|
+
7f7: 48 99 cqto
|
199
|
+
7f9: 48 f7 7d c8 idivq -0x38(%rbp)
|
200
|
+
7fd: 48 89 45 c0 mov %rax,-0x40(%rbp)
|
201
|
+
801: 48 83 45 f8 01 addq $0x1,-0x8(%rbp)
|
202
|
+
806: 48 81 7d f8 00 e1 f5 cmpq $0x5f5e100,-0x8(%rbp)
|
203
|
+
80d: 05
|
204
|
+
80e: 7e e3 jle 7f3 <main+0x169>
|
205
|
+
810: e8 3b fd ff ff callq 550 <clock@plt>
|
206
|
+
815: 89 45 ec mov %eax,-0x14(%rbp)
|
207
|
+
818: 8b 45 ec mov -0x14(%rbp),%eax
|
208
|
+
81b: 2b 45 f0 sub -0x10(%rbp),%eax
|
209
|
+
81e: f2 0f 2a c0 cvtsi2sd %eax,%xmm0
|
210
|
+
822: f2 0f 10 0d 4e 01 00 movsd 0x14e(%rip),%xmm1 # 978 <_IO_stdin_used+0xa8>
|
211
|
+
829: 00
|
212
|
+
82a: f2 0f 5e c1 divsd %xmm1,%xmm0
|
213
|
+
82e: 48 8d 3d 1b 01 00 00 lea 0x11b(%rip),%rdi # 950 <_IO_stdin_used+0x80>
|
214
|
+
835: b8 01 00 00 00 mov $0x1,%eax
|
215
|
+
83a: e8 21 fd ff ff callq 560 <printf@plt>
|
216
|
+
83f: b8 00 00 00 00 mov $0x0,%eax
|
217
|
+
844: c9 leaveq
|
218
|
+
845: c3 retq
|
219
|
+
846: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
|
220
|
+
84d: 00 00 00
|
221
|
+
```
|
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -89,4 +89,6 @@
|
|
89
89
|
|
90
90
|
[追記]
|
91
91
|
書くのを忘れていました。最適化は行っていません。
|
92
|
-
今回の場合、最適化を行うと実験の意味がなくなってしまいます。
|
92
|
+
今回の場合、最適化を行うと実験の意味がなくなってしまいます。
|
93
|
+
|
94
|
+
CPUはIntelです。
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -85,4 +85,8 @@
|
|
85
85
|
アライメントが**超難しい**です。
|
86
86
|
|
87
87
|
わかる方いますか??
|
88
|
-
Linux 64bit OS で実験しました。
|
88
|
+
Linux 64bit OS で実験しました。
|
89
|
+
|
90
|
+
[追記]
|
91
|
+
書くのを忘れていました。最適化は行っていません。
|
92
|
+
今回の場合、最適化を行うと実験の意味がなくなってしまいます。
|