{"id":3072,"date":"2013-12-04T16:49:52","date_gmt":"2013-12-04T07:49:52","guid":{"rendered":"http:\/\/blog.bitmeister.jp\/?p=3072"},"modified":"2013-12-04T16:54:49","modified_gmt":"2013-12-04T07:54:49","slug":"%e3%82%b3%e3%83%b3%e3%83%91%e3%82%a4%e3%83%a9%e3%81%ae%e6%9c%80%e9%81%a9%e5%8c%96%e3%82%aa%e3%83%97%e3%82%b7%e3%83%a7%e3%83%b3","status":"publish","type":"post","link":"https:\/\/blog.bitmeister.jp\/?p=3072","title":{"rendered":"\u30b3\u30f3\u30d1\u30a4\u30e9\u306e\u6700\u9069\u5316\u30aa\u30d7\u30b7\u30e7\u30f3"},"content":{"rendered":"<p>\u4eca\u65e5\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u306e\u6700\u9069\u5316\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u5358\u7d14\u306a\u30eb\u30fc\u30d7\u3068\u6574\u6570\u6f14\u7b97\u3092\u3069\u306e\u304f\u3089\u3044\u9ad8\u901f\u5316\u3067\u304d\u308b\u304b\u3092\u898b\u3066\u307f\u307e\u3059\u3002<br \/>\n<!--more--><br \/>\n\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u3092C\u3067\u66f8\u304d\u307e\u3057\u305f\u30021\u304b\u3089\u30b3\u30de\u30f3\u30c9\u5f15\u6570\u306b\u6e21\u3057\u305f\u5024\u307e\u3067\u9806\u756a\u306b\u8db3\u3057\u5408\u308f\u305b\u308btest.c\u3067\u3059\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n\r\nint main(int argc, char *argv&#x5B;]) {\r\n  long long unsigned int i=0, j=0, a=atoll(argv&#x5B;1]);\r\n\r\n  while (i&lt;a)\r\n    j += ++i;\r\n\r\n  printf(&quot;%llu\\n&quot;, j);\r\n  return 0;\r\n}\r\n<\/pre>\n<p>&nbsp;<br \/>\n\u74b0\u5883\u306f Ubuntu 12.04 \u306e gcc version 4.6.3 \u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ gcc -v\r\n...\r\ngcc version 4.6.3 (Ubuntu\/Linaro 4.6.3-1ubuntu5)\r\n<\/pre>\n<p>&nbsp;<br \/>\n\u307e\u305a\u306f\u3001\u666e\u901a\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ gcc test.c\r\n$ time .\/a.out 9876543210\r\n11879564747017720423\r\n\r\nreal\t0m21.469s\r\nuser\t0m21.469s\r\nsys\t0m0.000s\r\n<\/pre>\n<p>&nbsp;<br \/>\n1\u304b\u30899876543210\u307e\u3067\u8db3\u3057\u5408\u308f\u305b\u308b\u306e\u306b21\u79d2\u304b\u304b\u308a\u307e\u3057\u305f\u3002\u3055\u3066\u3001\u6700\u9069\u5316\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u3061\u306a\u307f\u306b -O2 \u3067\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u898b\u308b\u306b\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3061\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ gcc -c -Q -O2 --help=optimizers | grep enabled\r\n  -falign-functions           \t\t&#x5B;enabled]\r\n  -falign-jumps               \t\t&#x5B;enabled]\r\n  -falign-labels              \t\t&#x5B;enabled]\r\n  -falign-loops               \t\t&#x5B;enabled]\r\n  -fasynchronous-unwind-tables \t\t&#x5B;enabled]\r\n  -fbranch-count-reg          \t\t&#x5B;enabled]\r\n  -fcaller-saves              \t\t&#x5B;enabled]\r\n  -fcombine-stack-adjustments \t\t&#x5B;enabled]\r\n...\r\n<\/pre>\n<p>&nbsp;<br \/>\n\u3046\u30fc\u3093\u3002\u306a\u3093\u3068\u306a\u304f\u4f55\u3092\u3057\u3066\u304f\u308c\u308b\u304b\u308f\u304b\u308b\u306e\u3082\u3042\u308c\u3070\u3001\u3088\u304f\u308f\u304b\u3089\u306a\u3044\u306e\u3082\u3042\u308a\u307e\u3059\u3002\u3061\u3083\u3093\u3068\u77e5\u308a\u305f\u3044\u3068\u304d\u306fman\u3092\u8aad\u3081\u3070\u3044\u3044\u3093\u3058\u3083\u306a\u3044\u304b\u306a\u3002\u3068\u308a\u3042\u3048\u305a\u5b9f\u884c\u901f\u5ea6\u304c\u3069\u3046\u306a\u308b\u306e\u304b\u77e5\u308a\u305f\u3044\u3060\u3051\u306a\u306e\u3067 -O2 \u3092\u6307\u5b9a\u3057\u3066\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ gcc test.c -O2\r\n$ time .\/a.out 9876543210\r\n11879564747017720423\r\n\r\nreal\t0m2.755s\r\nuser\t0m2.748s\r\nsys\t0m0.004s\r\n<\/pre>\n<p>&nbsp;<br \/>\n\u304a\u3049\u3001\u901f\u304f\u306a\u3063\u305f\u3001\u901f\u304f\u306a\u3063\u305f\u3002\u3069\u3093\u306a\u7406\u5c48\u3067\u901f\u304f\u306a\u3063\u3066\u308b\u304b\u306f\u8b0e\u3067\u3059\u304c\u3001\u3061\u3083\u3093\u30689876543210\u30b5\u30a4\u30af\u30eb\u306e\u8a08\u7b97\u3092\u3057\u3066\u308b\u6c17\u3082\u3057\u307e\u3059\u3002\u8a73\u3057\u304f\u8abf\u3079\u3066\u307f\u308b\u3068\u9762\u767d\u305d\u3046\u3002\u305b\u3063\u304b\u304f\u3060\u304b\u3089 Mac OS X Mavericks \u3067\u3082\u3084\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ gcc test.c -O\r\n$ time .\/a.out 9876543210\r\n11879564747017720423\r\n\r\nreal\t0m0.005s\r\nuser\t0m0.001s\r\nsys\t0m0.002s\r\n<\/pre>\n<p>&nbsp;<br \/>\n\u306a\u306b\u3053\u308c\u901f\u3059\u304e\u3002 Mavericks \u306e xcode \u306b\u5165\u3063\u3066\u308b\u30b3\u30f3\u30d1\u30a4\u30e9\u306f\u3001\u300c\u3053\u308c\u3063\u3066\u7b49\u5dee\u6570\u5217\u306e\u548c\u3092\u8a08\u7b97\u3057\u3066\u308b\u3093\u3060\u304b\u3089\u3001\u30eb\u30fc\u30d7\u306a\u3093\u3066\u5fc5\u8981\u306a\u3044\u3058\u3083\u3093\u300d\u3066\u3053\u3068\u3092\u89e3\u6790\u3057\u3066\u308b\u3063\u307d\u3044\u3002\u3053\u306e\u30b3\u30f3\u30d1\u30a4\u30e9\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u3092\u898b\u3066\u307f\u308b\u3068\u3001<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ gcc -v\r\n...\r\nApple LLVM version 5.0 (clang-500.2.79) ...\r\n<\/pre>\n<p>&nbsp;<br \/>\n\u3053\u308c gcc \u3084\u306a\u3044\u3001LLVM clang \u3084\u3002\u3069\u3046\u3084\u3089 Mac OS X Mavericks \u306e gcc \u30b3\u30de\u30f3\u30c9\u306e\u4e2d\u8eab\u306f LLVM clang \u307f\u305f\u3044\u3067\u3059\u3002 LLVM \u304b\u3057\u3053\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u65e5\u306f\u30b3\u30f3\u30d1\u30a4\u30eb\u306e\u6700\u9069\u5316\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u5358\u7d14\u306a\u30eb\u30fc\u30d7\u3068\u6574\u6570\u6f14\u7b97\u3092\u3069\u306e\u304f\u3089\u3044\u9ad8\u901f\u5316\u3067\u304d\u308b\u304b\u3092\u898b\u3066\u307f\u307e\u3059\u3002<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-3072","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/3072","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3072"}],"version-history":[{"count":37,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/3072\/revisions"}],"predecessor-version":[{"id":3109,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/3072\/revisions\/3109"}],"wp:attachment":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}