{"id":348052,"date":"2023-05-29T21:05:19","date_gmt":"2023-05-29T21:05:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=348052"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=348052","title":{"rendered":"<span>\u041a\u0430\u043a IndVarSimplification \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443 \u0432 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>\u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0435\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0435\u043e\u0431\u044b\u0447\u043d\u0430 \u043e\u043d\u0430 \u0432 \u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0435\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c!<\/p>\n<details class=\"spoiler\">\n<summary>\u0427\u0435\u043c \u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0415\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442: <a href=\"https:\/\/godbolt.org\/\" rel=\"noopener noreferrer nofollow\">Compiler Explorer<\/a>. \u0422\u0443\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f. \u041f\u043e\u043c\u0438\u043c\u043e \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 LLVM \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439.<\/p>\n<\/div>\n<\/details>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Rust:<\/p>\n<pre><code class=\"rust\">pub fn fancy_function(n: u64) -&gt; u64 {     let mut sum = 0;     for i in 0..n {         sum += i;     }     sum }<\/code><\/pre>\n<p>\u0414\u0430\u0436\u0435 \u043b\u044e\u0434\u0438, \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u0441 Rust, \u0441\u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442: \u0437\u0430\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>sum<\/code>, \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043f\u043e \u0447\u0438\u0441\u043b\u0430\u043c \u043e\u0442 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"0\" alt=\"0\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/be7\/bbc\/717\/be7bbc71714cfcaec7284a9d5740ab4a.svg\" width=\"10\" height=\"17\">\u0434\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(n - 1)\" alt=\"(n - 1)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e50\/c00\/00d\/e50c0000dbe5b4db1f0f9799641ccf9a.svg\" width=\"61\" height=\"22\">\u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u043c \u0438\u0445. \u0421\u0443\u043c\u043c\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0433\u043b\u044f\u043d\u0435\u043c \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/421\/2b7\/71f\/4212b771f4585988b5434685783ef88e.png\" alt=\"x86_64, AT&amp;T asm syntax\" title=\"x86_64, AT&amp;T asm syntax\" width=\"660\" height=\"270\"><\/p>\n<div><figcaption>x86_64, AT&amp;T asm syntax<\/figcaption><\/div>\n<\/figure>\n<p>\u042f \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043b \u044d\u0442\u043e \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0430 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432. \u0417\u0435\u043b\u0435\u043d\u0430\u044f \u0432\u0435\u0442\u043a\u0430 &#8212; \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b, \u043a\u0440\u0430\u0441\u043d\u0430\u044f &#8212; \u0435\u0441\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0442\u0443\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u043d\u0435\u0442 \u0446\u0438\u043a\u043b\u043e\u0432 \u0432\u043e\u043e\u0431\u0449\u0435. \u041a\u0430\u043a \u0436\u0435 \u0442\u043e\u0433\u0434\u0430 \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f? \u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0432 \u043f\u0440\u0430\u0432\u0443\u044e \u0432\u0435\u0442\u043a\u0443, \u044f \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u0448\u043a\u043e\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u0447\u0442\u043e:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"1 + 2 + \\dots + (n - 1) = \\frac{n(n - 1)}{2}\" alt=\"1 + 2 + \\dots + (n - 1) = \\frac{n(n - 1)}{2}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3e9\/f88\/318\/3e9f883189ae88c05068877632c379da.svg\" width=\"281\" height=\"45\"><\/p>\n<p>\u0414\u0430, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e \u0442\u0430\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0435 \u0432\u0441\u0435 \u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443:<\/p>\n<pre><code class=\"rust\">pub fn fancy_function(n: u64) -&gt; u64 {     let mut sum = 0;     for i in 0..n {         sum += i * i * i + 2 * i * i + 3 * i + 42;     }     sum }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0443\u043c\u043c\u0443 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432 3 \u0441\u0442\u0435\u043f\u0435\u043d\u0438. \u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u044f \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u044e, \u043a\u0430\u043a \u043d\u0430\u043c \u0432 \u0443\u043d\u0438\u0432\u0435\u0440\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438, \u0447\u0442\u043e \u0441\u0443\u043c\u043c\u0443 \u043b\u044e\u0431\u044b\u0445 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u043e\u0442 <code>n<\/code>. \u0412\u044b\u0432\u0435\u0434\u0435\u0442 \u043b\u0438 \u044d\u0442\u0443 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440?<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a3a\/45f\/c51\/a3a45fc512229524892efe24ba76570d.png\" alt=\"x86_64, AT&amp;T asm syntax\" title=\"x86_64, AT&amp;T asm syntax\" width=\"756\" height=\"622\"><\/p>\n<div><figcaption>x86_64, AT&amp;T asm syntax<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430, \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e! \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"O(1)\" alt=\"O(1)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1f8\/166\/a15\/1f8166a156464ad231b606d457d16e87.svg\" width=\"40\" height=\"22\">.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u043c\u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0442\u043e, \u0432 \u043a\u0430\u043a\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438 \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u044d\u0442\u0443 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e, \u0438 \u044f \u043d\u0430\u0447\u0430\u043b \u0441 <a href=\"https:\/\/rustc-dev-guide.rust-lang.org\/overview.html\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 Rust<\/a>. \u0415\u0441\u043b\u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435, \u0442\u043e \u043a\u043e\u0434 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Rust \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0434\u0432\u0443\u0445 \u043c\u0435\u0441\u0442\u0430\u0445:<\/p>\n<ul>\n<li>\n<p><em>Mid-level Intermediate Representation (MIR)<\/em> &#8212; \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0431\u0440\u0430\u043d \u0432\u0435\u0441\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440 \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u044b \u0442\u0438\u043f\u044b \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u044f\u0437\u044b\u043a\u0430 Rust.<\/p>\n<\/li>\n<li>\n<p><em>LLVM Intermediate Representation (LLVM-IR)<\/em> &#8212; \u0444\u043e\u0440\u043c\u0430\u0442 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 LLVM \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 LLVM.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 MIR. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0431\u0435\u0440\u0435\u043c nightly \u0432\u0435\u0440\u0441\u0438\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 Rust \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u044f \u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441 \u0441\u0443\u043c\u043c\u043e\u0439 \u043e\u0442 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"0\" alt=\"0\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/79b\/d65\/ce2\/79bd65ce22fae2703cf8d6a27e9eb914.svg\" width=\"10\" height=\"17\">\u0434\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(n - 1)\" alt=\"(n - 1)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5f7\/e40\/48a\/5f7e4048a3dcb697db258cc182dcd8e0.svg\" width=\"61\" height=\"22\"><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b38\/841\/81e\/b3884181ef57e9af068a30dddd911b61.png\" alt=\"rustc -Z mir-opt-level=0 -C opt-level=3\" title=\"rustc -Z mir-opt-level=0 -C opt-level=3\" width=\"660\" height=\"270\"><\/p>\n<div><figcaption>rustc -Z mir-opt-level=0 -C opt-level=3<\/figcaption><\/div>\n<\/figure>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 MIR \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 LLVM:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d07\/037\/ac3\/d07037ac37e9f6f95b17e77264e40c16.png\" alt=\"rustc -Z mir-opt-level=4 -C opt-level=0\" title=\"rustc -Z mir-opt-level=4 -C opt-level=0\" width=\"1955\" height=\"665\"><\/p>\n<div><figcaption>rustc -Z mir-opt-level=4 -C opt-level=0<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0438\u0434\u0438\u0442\u0435 \u0433\u043e\u043b\u0443\u0431\u0443\u044e \u0441\u0442\u0440\u0435\u043b\u043e\u0447\u043a\u0443 \u043d\u0430\u0432\u0435\u0440\u0445? \u042d\u0442\u043e \u0446\u0438\u043a\u043b! \u0418 \u0434\u0430\u0436\u0435 \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412\u044b\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 LLVM? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c.<\/p>\n<p>\u0412 Compiler Explorer \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439, \u0438 \u0441\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 \u044f \u043d\u0430\u0448\u0435\u043b \u0442\u0430\u043a\u0443\u044e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e43\/c0b\/629\/e43c0b6292bd0636e97c3ddfbd64dcbd.png\" alt=\"\u0421\u043b\u0435\u0432\u0430 - \u0434\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u043f\u0440\u0430\u0432\u0430 - \u043f\u043e\u0441\u043b\u0435\" title=\"\u0421\u043b\u0435\u0432\u0430 - \u0434\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u043f\u0440\u0430\u0432\u0430 - \u043f\u043e\u0441\u043b\u0435\" width=\"2204\" height=\"1314\"><\/p>\n<div><figcaption>\u0421\u043b\u0435\u0432\u0430 &#8212; \u0434\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u043f\u0440\u0430\u0432\u0430 &#8212; \u043f\u043e\u0441\u043b\u0435<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f IndVarSimplifyPass. \u0422\u0443\u0442 \u0431\u044b\u043b\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u043e \u0442\u0435\u043b\u043e \u0446\u0438\u043a\u043b\u0430 \u0438 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"n(n - 1) \/ 2\" alt=\"n(n - 1) \/ 2\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3a1\/d9a\/eaf\/3a1d9aeaf10bd8b65588bcb61bd236f4.svg\" width=\"92\" height=\"22\">. \u0410 \u0442\u043e, \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043e\u0442 \u0446\u0438\u043a\u043b\u0430, \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u043e \u043f\u043e\u0437\u0436\u0435 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438.<\/p>\n<p>\u0411\u0435\u0433\u043b\u044b\u043c \u0432\u0437\u0433\u043b\u044f\u0434\u043e\u043c \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u0432\u0448\u0438\u0441\u044c \u043f\u043e <a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Transforms\/Scalar\/IndVarSimplify.cpp\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 IndVarSimplifyPass<\/a>, \u044f \u043d\u0430\u0448\u0435\u043b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0441\u044f &#171;\u043c\u0430\u0433\u0438\u044f&#187; \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>Scalar Evolution Evaluation<\/em>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c46\/cad\/dd6\/c46caddd69934b7fa716737f6b977811.png\" alt=\"\u0425\u043e\u0440\u043e\u0448\u043e, \u043a\u043e\u0433\u0434\u0430 \u043b\u044e\u0434\u0438 \u043f\u0438\u0448\u0443\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 :)\" title=\"\u0425\u043e\u0440\u043e\u0448\u043e, \u043a\u043e\u0433\u0434\u0430 \u043b\u044e\u0434\u0438 \u043f\u0438\u0448\u0443\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 :)\" width=\"1332\" height=\"312\"><\/p>\n<div><figcaption>\u0425\u043e\u0440\u043e\u0448\u043e, \u043a\u043e\u0433\u0434\u0430 \u043b\u044e\u0434\u0438 \u043f\u0438\u0448\u0443\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \ud83d\ude42<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0447\u0438\u0442\u0430\u0442\u044c \u0435\u0433\u043e <a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Analysis\/ScalarEvolution.cpp\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a>, \u044f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b <a href=\"https:\/\/www.youtube.com\/watch?v=AmjliNp0_00\" rel=\"noopener noreferrer nofollow\">\u0432\u0438\u0434\u0435\u043e \u043d\u0430 YouTube<\/a> \u043e\u0442 LLVM, \u0433\u0434\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f  <em>SCEV Evaluation<\/em>, \u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u0430\u043a\u0430\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0437\u0430 \u044d\u0442\u0438\u043c \u0441\u0442\u043e\u0438\u0442.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435, \u0442\u043e \u0431\u044b\u0432\u0430\u044e\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0440\u0435\u043a\u0443\u0440\u0440\u0435\u043d\u0442\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u043d\u043e\u0442\u0430\u0446\u0438\u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\{b, +, c\\}\" alt=\"\\{b, +, c\\}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/73c\/d03\/c21\/73cd03c217019d421d2ec2cd88b7f810.svg\" width=\"69\" height=\"22\">:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\{b, +, c\\} = b, b + c, b + 2c, b + 3c, \\dots\" alt=\"\\{b, +, c\\} = b, b + c, b + 2c, b + 3c, \\dots\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2cf\/98d\/479\/2cf98d479edddbee029541d65e34e467.svg\" width=\"303\" height=\"22\"><\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0438\u044f. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u044b\u0448\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\{a, +, b, +, c\\} =\\{a, +, \\{b, +, c\\}\\}  = a, a + b, a + 2b + c, a + 3b + 3c, a + 4b + 6c, \\dots\" alt=\"\\{a, +, b, +, c\\} =\\{a, +, \\{b, +, c\\}\\}  = a, a + b, a + 2b + c, a + 3b + 3c, a + 4b + 6c, \\dots\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/437\/518\/0c9\/4375180c9ecc46ce4601db3715d699e0.svg\" width=\"690\" height=\"22\"><\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"a\" alt=\"a\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b9d\/bc8\/adb\/b9dbc8adb84b89c97c446551fcf47ad5.svg\" width=\"10\" height=\"12\">, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0438\u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\{b, +, c\\}\" alt=\"\\{b, +, c\\}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ca7\/711\/04e\/ca771104e84b97e94c8a2e1f6895a5f6.svg\" width=\"69\" height=\"22\">. \u041c\u043e\u0436\u043d\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0441\u0443\u043c\u043c\u0443 i-\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\{x_1, +, x_2, +, \\dots, +, x_n\\}_i = x_1 \\binom{i}{0} + x_2 \\binom{i}{1} + \\ldots + x_n \\binom{i}{n - 1}\" alt=\"\\{x_1, +, x_2, +, \\dots, +, x_n\\}_i = x_1 \\binom{i}{0} + x_2 \\binom{i}{1} + \\ldots + x_n \\binom{i}{n - 1}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/67b\/daa\/74e\/67bdaa74e9ecdab853fcc41dc129d200.svg\" width=\"546\" height=\"50\"><\/p>\n<p>\u0410 \u0441\u0443\u043c\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\sum_{i = 1}^n \\{x_1, +, \\dots, +, x_n\\} = \\{0, +, x_1, +, \\dots, +, x_n\\}_n\" alt=\"\\sum_{i = 1}^n \\{x_1, +, \\dots, +, x_n\\} = \\{0, +, x_1, +, \\dots, +, x_n\\}_n\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/84f\/170\/7ee\/84f1707ee03a1d3f78ae3cd80ce3f9ee.svg\" width=\"412\" height=\"57\"><\/p>\n<p>\u0410 \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0442\u0430\u043a\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0438 \u0443\u043c\u043d\u043e\u0436\u0430\u0442\u044c.<\/p>\n<p>\u0418 \u0432\u043e\u0442, \u043f\u0440\u043e\u0433\u043b\u044f\u0434\u0435\u0432 \u043a\u043e\u0434 <em>SCEV Evaluation<\/em>, \u044f \u043d\u0430\u0448\u0435\u043b \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Analysis\/ScalarEvolution.cpp#L857\" rel=\"noopener noreferrer nofollow\">\u0422\u0443\u0442<\/a> \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Analysis\/ScalarEvolution.cpp#L975\" rel=\"noopener noreferrer nofollow\">\u0422\u0443\u0442<\/a> \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f i-\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Analysis\/ScalarEvolution.cpp#L2518\" rel=\"noopener noreferrer nofollow\">\u0422\u0443\u0442<\/a> \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0443\u043c\u043c\u0430 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439<\/p>\n<\/li>\n<li>\n<p>\u0410 <a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Analysis\/ScalarEvolution.cpp#L3113\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a> \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c, \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0430\u0440\u0441\u0435\u0440 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430 i-\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 (\u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 \u043e\u0442 i), \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430 \u0441\u0443\u043c\u043c\u044b \u044d\u0442\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0438 i \u043e\u0442 0 \u0434\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"(n - 1)\" alt=\"(n - 1)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d92\/40f\/997\/d9240f997bf7df36a5574e060ce9df82.svg\" width=\"61\" height=\"22\">\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f74\/515\/44f\/f7451544f23427592c35f24656966412.jpg\" alt=\"\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u044f.\" title=\"\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u044f.\" width=\"1182\" height=\"430\"><\/p>\n<div><figcaption>\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u044f.<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u043e\u0434 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0432 \u043c\u043e\u0435\u043c <a href=\"https:\/\/github.com\/tagirhamitov\/recurrents\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0445\u043e\u0447\u0443 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u043c\u044b\u0441\u043b\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0430\u0437 \u043f\u043e\u0434\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438, \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0432 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/738272\/\"> https:\/\/habr.com\/ru\/articles\/738272\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>\u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0435\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0435\u043e\u0431\u044b\u0447\u043d\u0430 \u043e\u043d\u0430 \u0432 \u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0435\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c!<\/p>\n<details class=\"spoiler\">\n<summary>\u0427\u0435\u043c \u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0415\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442: <a href=\"https:\/\/godbolt.org\/\" rel=\"noopener noreferrer nofollow\">Compiler Explorer<\/a>. \u0422\u0443\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f. \u041f\u043e\u043c\u0438\u043c\u043e \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 LLVM \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439.<\/p>\n<\/div>\n<\/details>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Rust:<\/p>\n<pre><code class=\"rust\">pub fn fancy_function(n: u64) -&gt; u64 {     let mut sum = 0;     for i in 0..n {         sum += i;     }     sum }<\/code><\/pre>\n<p>\u0414\u0430\u0436\u0435 \u043b\u044e\u0434\u0438, \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u0441 Rust, \u0441\u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442: \u0437\u0430\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>sum<\/code>, \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043f\u043e \u0447\u0438\u0441\u043b\u0430\u043c \u043e\u0442 \u0434\u043e \u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u043c \u0438\u0445. \u0421\u0443\u043c\u043c\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0433\u043b\u044f\u043d\u0435\u043c \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>x86_64, AT&amp;T asm syntax<\/figcaption><\/div>\n<\/figure>\n<p>\u042f \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043b \u044d\u0442\u043e \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0430 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432. \u0417\u0435\u043b\u0435\u043d\u0430\u044f \u0432\u0435\u0442\u043a\u0430 &#8212; \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b, \u043a\u0440\u0430\u0441\u043d\u0430\u044f &#8212; \u0435\u0441\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0442\u0443\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u043d\u0435\u0442 \u0446\u0438\u043a\u043b\u043e\u0432 \u0432\u043e\u043e\u0431\u0449\u0435. \u041a\u0430\u043a \u0436\u0435 \u0442\u043e\u0433\u0434\u0430 \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f? \u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0432 \u043f\u0440\u0430\u0432\u0443\u044e \u0432\u0435\u0442\u043a\u0443, \u044f \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u0448\u043a\u043e\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u0447\u0442\u043e:<\/p>\n<p>\u0414\u0430, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e \u0442\u0430\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0435 \u0432\u0441\u0435 \u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443:<\/p>\n<pre><code class=\"rust\">pub fn fancy_function(n: u64) -&gt; u64 {     let mut sum = 0;     for i in 0..n {         sum += i * i * i + 2 * i * i + 3 * i + 42;     }     sum }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0443\u043c\u043c\u0443 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432 3 \u0441\u0442\u0435\u043f\u0435\u043d\u0438. \u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u044f \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u044e, \u043a\u0430\u043a \u043d\u0430\u043c \u0432 \u0443\u043d\u0438\u0432\u0435\u0440\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438, \u0447\u0442\u043e \u0441\u0443\u043c\u043c\u0443 \u043b\u044e\u0431\u044b\u0445 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u043e\u0442 <code>n<\/code>. \u0412\u044b\u0432\u0435\u0434\u0435\u0442 \u043b\u0438 \u044d\u0442\u0443 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440?<\/p>\n<figure class=\"full-width\">\n<div><figcaption>x86_64, AT&amp;T asm syntax<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430, \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e! \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0435\u0449\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430 .<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u043c\u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0442\u043e, \u0432 \u043a\u0430\u043a\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438 \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u044d\u0442\u0443 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e, \u0438 \u044f \u043d\u0430\u0447\u0430\u043b \u0441 <a href=\"https:\/\/rustc-dev-guide.rust-lang.org\/overview.html\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 Rust<\/a>. \u0415\u0441\u043b\u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435, \u0442\u043e \u043a\u043e\u0434 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Rust \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0434\u0432\u0443\u0445 \u043c\u0435\u0441\u0442\u0430\u0445:<\/p>\n<ul>\n<li>\n<p><em>Mid-level Intermediate Representation (MIR)<\/em> &#8212; \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0431\u0440\u0430\u043d \u0432\u0435\u0441\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440 \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u044b \u0442\u0438\u043f\u044b \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u044f\u0437\u044b\u043a\u0430 Rust.<\/p>\n<\/li>\n<li>\n<p><em>LLVM Intermediate Representation (LLVM-IR)<\/em> &#8212; \u0444\u043e\u0440\u043c\u0430\u0442 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 LLVM \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 LLVM.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 MIR. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0431\u0435\u0440\u0435\u043c nightly \u0432\u0435\u0440\u0441\u0438\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 Rust \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u044f \u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441 \u0441\u0443\u043c\u043c\u043e\u0439 \u043e\u0442 \u0434\u043e <\/p>\n<figure class=\"full-width\">\n<div><figcaption>rustc -Z mir-opt-level=0 -C opt-level=3<\/figcaption><\/div>\n<\/figure>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 MIR \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 LLVM:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>rustc -Z mir-opt-level=4 -C opt-level=0<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0438\u0434\u0438\u0442\u0435 \u0433\u043e\u043b\u0443\u0431\u0443\u044e \u0441\u0442\u0440\u0435\u043b\u043e\u0447\u043a\u0443 \u043d\u0430\u0432\u0435\u0440\u0445? \u042d\u0442\u043e \u0446\u0438\u043a\u043b! \u0418 \u0434\u0430\u0436\u0435 \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412\u044b\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 LLVM? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c.<\/p>\n<p>\u0412 Compiler Explorer \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439, \u0438 \u0441\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 \u044f \u043d\u0430\u0448\u0435\u043b \u0442\u0430\u043a\u0443\u044e:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043b\u0435\u0432\u0430 &#8212; \u0434\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u043f\u0440\u0430\u0432\u0430 &#8212; \u043f\u043e\u0441\u043b\u0435<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f IndVarSimplifyPass. \u0422\u0443\u0442 \u0431\u044b\u043b\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u043e \u0442\u0435\u043b\u043e \u0446\u0438\u043a\u043b\u0430 \u0438 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b . \u0410 \u0442\u043e, \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043e\u0442 \u0446\u0438\u043a\u043b\u0430, \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u043e \u043f\u043e\u0437\u0436\u0435 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438.<\/p>\n<p>\u0411\u0435\u0433\u043b\u044b\u043c \u0432\u0437\u0433\u043b\u044f\u0434\u043e\u043c \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u0432\u0448\u0438\u0441\u044c \u043f\u043e <a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Transforms\/Scalar\/IndVarSimplify.cpp\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 IndVarSimplifyPass<\/a>, \u044f \u043d\u0430\u0448\u0435\u043b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0441\u044f &#171;\u043c\u0430\u0433\u0438\u044f&#187; \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>Scalar Evolution Evaluation<\/em>.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0425\u043e\u0440\u043e\u0448\u043e, \u043a\u043e\u0433\u0434\u0430 \u043b\u044e\u0434\u0438 \u043f\u0438\u0448\u0443\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \ud83d\ude42<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0447\u0438\u0442\u0430\u0442\u044c \u0435\u0433\u043e <a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Analysis\/ScalarEvolution.cpp\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a>, \u044f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b <a href=\"https:\/\/www.youtube.com\/watch?v=AmjliNp0_00\" rel=\"noopener noreferrer nofollow\">\u0432\u0438\u0434\u0435\u043e \u043d\u0430 YouTube<\/a> \u043e\u0442 LLVM, \u0433\u0434\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f  <em>SCEV Evaluation<\/em>, \u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u0430\u043a\u0430\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0437\u0430 \u044d\u0442\u0438\u043c \u0441\u0442\u043e\u0438\u0442.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435, \u0442\u043e \u0431\u044b\u0432\u0430\u044e\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0440\u0435\u043a\u0443\u0440\u0440\u0435\u043d\u0442\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u043d\u043e\u0442\u0430\u0446\u0438\u0438 :<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0438\u044f. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u044b\u0448\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e:<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 , \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0438\u0438 . \u041c\u043e\u0436\u043d\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0441\u0443\u043c\u043c\u0443 i-\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430:<\/p>\n<p>\u0410 \u0441\u0443\u043c\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>\u0410 \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0442\u0430\u043a\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0438 \u0443\u043c\u043d\u043e\u0436\u0430\u0442\u044c.<\/p>\n<p>\u0418 \u0432\u043e\u0442, \u043f\u0440\u043e\u0433\u043b\u044f\u0434\u0435\u0432 \u043a\u043e\u0434 <em>SCEV Evaluation<\/em>, \u044f \u043d\u0430\u0448\u0435\u043b \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Analysis\/ScalarEvolution.cpp#L857\" rel=\"noopener noreferrer nofollow\">\u0422\u0443\u0442<\/a> \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Analysis\/ScalarEvolution.cpp#L975\" rel=\"noopener noreferrer nofollow\">\u0422\u0443\u0442<\/a> \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f i-\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Analysis\/ScalarEvolution.cpp#L2518\" rel=\"noopener noreferrer nofollow\">\u0422\u0443\u0442<\/a> \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0443\u043c\u043c\u0430 \u0434\u0432\u0443\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439<\/p>\n<\/li>\n<li>\n<p>\u0410 <a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/llvm\/lib\/Analysis\/ScalarEvolution.cpp#L3113\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a> \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c, \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0430\u0440\u0441\u0435\u0440 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430 i-\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 (\u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 \u043e\u0442 i), \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430 \u0441\u0443\u043c\u043c\u044b \u044d\u0442\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0438 i \u043e\u0442 0 \u0434\u043e \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u044f.<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u043e\u0434 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0432 \u043c\u043e\u0435\u043c <a href=\"https:\/\/github.com\/tagirhamitov\/recurrents\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0445\u043e\u0447\u0443 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u043c\u044b\u0441\u043b\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0430\u0437 \u043f\u043e\u0434\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438, \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0432 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/738272\/\"> https:\/\/habr.com\/ru\/articles\/738272\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-348052","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=348052"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348052\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=348052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=348052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=348052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}