{"id":7429,"date":"2020-01-18T00:15:43","date_gmt":"2020-01-17T15:15:43","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=7429"},"modified":"2020-01-18T00:15:43","modified_gmt":"2020-01-17T15:15:43","slug":"c-c-%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%e3%81%ae%e5%85%b7%e4%bd%93%e7%9a%84%e3%81%aa%e4%b8%ad%e8%ba%ab","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=7429","title":{"rendered":"C\/C++ \u30b3\u30f3\u30d1\u30a4\u30e9\u306e\u6700\u9069\u5316\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u5177\u4f53\u7684\u306a\u4e2d\u8eab"},"content":{"rendered":"<p>GCC \u306a\u308a Clang \u306a\u308a MSVC \u306a\u308a\u3092\u4f7f\u3046\u5834\u5408\u3001\u666e\u901a\u306f\u6700\u9069\u5316\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u3057\u3066\u306f <code>-O2<\/code> \u306a\u3069\u3068\u3060\u3051\u6307\u5b9a\u3057\u307e\u3059\u3002\u5b9f\u969b\u306b\u306f\u3053\u306e <code>-O2<\/code> \u306f\u3044\u308d\u3044\u308d\u306a\u6700\u9069\u5316\u624b\u6cd5\u306e\u96c6\u5408\u3092\u6709\u52b9\u5316\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u306a\u306e\u3067\u3059\u304c\u3001\u3058\u3083\u3042\u305d\u306e\u96c6\u5408\u3092\u77e5\u308a\u305f\u304f\u306a\u3063\u305f\u3089\u3069\u3046\u3057\u307e\u3057\u3087\u3046\u3001\u3068\u3044\u3046\u306e\u304c\u3053\u306e\u8a18\u4e8b\u306e\u304a\u8a71\u3067\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<h3>MSVC (Visual C++) \u306e\u5834\u5408<\/h3>\n<p>MSVC \u306e\u5834\u5408\u306f <a href=\"https:\/\/docs.microsoft.com\/ja-jp\/cpp\/build\/reference\/o-options-optimize-code\">MSDN \u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u8aac\u660e\u306e\u30da\u30fc\u30b8<\/a>\u306b\u305d\u306e\u3082\u306e\u30ba\u30d0\u30ea\u66f8\u3044\u3066\u3042\u308a\u307e\u3059\u3002\u5f8c\u8ff0\u306e GCC \u3084 Clang \u3068\u6bd4\u3079\u308b\u3068 MSVC \u306f\u6700\u9069\u5316\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u7c92\u5ea6\u304c\u7c97\u3044\u3053\u3068\u304c\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n<h3>GCC \u306e\u5834\u5408<\/h3>\n<p><a href=\"https:\/\/gcc.gnu.org\/onlinedocs\/gcc-9.2.0\/gcc\/Optimize-Options.html\">\u30aa\u30f3\u30e9\u30a4\u30f3\u30de\u30cb\u30e5\u30a2\u30eb<\/a>\u3092\u898b\u308b\u3068\u66f8\u3044\u3066\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u624b\u5143\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306e GCC \u306b\u3064\u3044\u3066\u8abf\u3079\u305f\u3044\u5834\u5408\u306f\u3001<\/p>\n<blockquote>\n<pre>\r\ngcc -Q -O2 --help=optimizers\r\n<\/pre>\n<\/blockquote>\n<p>\u306a\u3069\u3068\u3059\u308b\u3068\u5177\u4f53\u7684\u306a\u8a2d\u5b9a\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3>Clang \u306e\u5834\u5408<\/h3>\n<p>Clang \u306e\u5834\u5408\u306f\u30b5\u30af\u30c3\u3068\u898b\u3064\u3051\u3089\u308c\u306a\u304b\u3063\u305f\uff08\u30de\u30cb\u30e5\u30a2\u30eb\u3068\u304b\u898b\u3066\u3082\u305d\u308c\u305e\u308c\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u3069\u3046\u3044\u3046\u4f4d\u7f6e\u3065\u3051\u306a\u306e\u304b\u3057\u304b\u66f8\u3044\u3066\u306a\u3044\uff09\u306e\u3067\u3059\u304c\u3001<a href=\"https:\/\/stackoverflow.com\/questions\/15548023\/clang-optimization-levels\">Stack Overflow \u306b\u305d\u3046\u3044\u3046\u8cea\u554f\u304c\u3042\u308b<\/a>\u3068\u3044\u3046\u3053\u3068\u3092<a href=\"https:\/\/twitter.com\/yottui\/status\/1218142171636715520\">\u6559\u3048\u3066\u3082\u3089\u3044\u307e\u3057\u305f<\/a>\u3002<\/p>\n<blockquote>\n<pre>\r\n# LLVM \u30ec\u30d9\u30eb\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u77e5\u308a\u305f\u3044\u5834\u5408\r\nllvm-as < \/dev\/null | opt -O2 -disable-output -debug-pass=Arguments\r\n\r\n# Clang \u304c\u72ec\u81ea\u306b\u8ffd\u52a0\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u77e5\u308a\u305f\u3044\u5834\u5408\r\necho 'int;' | clang -xc -O2 - -o \/dev\/null -\\#\\#\\#\r\n<\/pre>\n<\/blockquote>\n<p>\u51fa\u529b\u304c\u8aad\u307f\u3065\u3089\u3044\u306e\u304c\u96e3\u70b9\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GCC \u306a\u308a Clang \u306a\u308a MSVC \u306a\u308a\u3092\u4f7f\u3046\u5834\u5408\u3001\u666e\u901a\u306f\u6700\u9069\u5316\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u3057\u3066\u306f -O2 \u306a\u3069\u3068\u3060\u3051\u6307\u5b9a\u3057\u307e\u3059\u3002\u5b9f\u969b\u306b\u306f\u3053\u306e -O2 \u306f\u3044\u308d\u3044\u308d\u306a\u6700\u9069\u5316\u624b\u6cd5\u306e\u96c6\u5408\u3092\u6709\u52b9\u5316\u3059\u308b\u30aa\u30d7\u30b7\u30e7\u30f3\u306a\u306e\u3067\u3059\u304c\u3001\u3058\u3083\u3042\u305d\u306e\u96c6\u5408\u3092 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-7429","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/7429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7429"}],"version-history":[{"count":2,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/7429\/revisions"}],"predecessor-version":[{"id":7431,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/7429\/revisions\/7431"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7429"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}