{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/2500","labels_url":"https://api.github.com/repos/dotnet/coreclr/issues/2500/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/2500/comments","events_url":"https://api.github.com/repos/dotnet/coreclr/issues/2500/events","html_url":"https://github.com/dotnet/coreclr/issues/2500","id":124559305,"number":2500,"title":"RyuJIT: [betternes] Handling boolean params when inlining methods","user":{"login":"omariom","id":1781701,"avatar_url":"https://avatars.githubusercontent.com/u/1781701?v=3","gravatar_id":"","url":"https://api.github.com/users/omariom","html_url":"https://github.com/omariom","followers_url":"https://api.github.com/users/omariom/followers","following_url":"https://api.github.com/users/omariom/following{/other_user}","gists_url":"https://api.github.com/users/omariom/gists{/gist_id}","starred_url":"https://api.github.com/users/omariom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omariom/subscriptions","organizations_url":"https://api.github.com/users/omariom/orgs","repos_url":"https://api.github.com/users/omariom/repos","events_url":"https://api.github.com/users/omariom/events{/privacy}","received_events_url":"https://api.github.com/users/omariom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-01T20:00:25Z","updated_at":"2016-01-01T20:00:25Z","closed_at":null,"body":"The following method..\r\n```C#\r\n[MethodImpl(MethodImplOptions.NoInlining)]\r\nstatic int TestInlinedCondition(Array obj)\r\n{\r\n        return obj.Length >= 15 ? 7 : 5;\r\n}\r\n\r\nstruct Array\r\n{\r\n    public readonly int Length;\r\n}\r\n```\r\nproduces this clean and clear code:\r\n```ASM\r\n; Assembly listing for method CoreClrTest.Program:TestInlinedCondition(struct):int\r\n; Emitting BLENDED_CODE for X64 CPU with SSE2\r\n; optimized code\r\n; rsp based frame\r\n; partially interruptible\r\n; Final local variable assignments\r\n;\r\n;* V00 arg0         [V00    ] (  0,   0  )  struct ( 8) zero-ref   \r\n;  V01 tmp0         [V01,T00] (  2,   2  )     int  ->  rcx         V00.Length(offs=0x00) P-INDEP\r\n;# V02 OutArgs      [V02    ] (  1,   1  )  lclBlk ( 0) [rsp+0x00]  \r\n;\r\n; Lcl frame size = 0\r\n\r\nG_M27976_IG01:\r\n\r\nG_M27976_IG02:\r\n       83F90F               cmp      ecx, 15\r\n       7D06                 jge      SHORT G_M27976_IG04\r\n       B805000000           mov      eax, 5\r\nG_M27976_IG03:\r\n       C3                   ret      \r\nG_M27976_IG04:\r\n       B807000000           mov      eax, 7\r\nG_M27976_IG05:\r\n       C3                   ret      \r\n; Total bytes of code 17, prolog size 0 for method CoreClrTest.Program:TestInlinedCondition(struct):int\r\n; ============================================================\r\n```\r\n\r\nBut If we encapsulate the calculation..\r\n```C#\r\n[MethodImpl(MethodImplOptions.NoInlining)]\r\nstatic int TestInlinedCondition(Array obj)\r\n{\r\n    return Calculator.Calc(obj.Length >= 15);\r\n}\r\n\r\nstatic class Calculator\r\n{\r\n    public static int Calc(bool condition)\r\n    {\r\n        return condition ? 7 : 5;\r\n    }\r\n}\r\n```\r\nthe code gets bigger and less nice:\r\n```ASM\r\n; Assembly listing for method CoreClrTest.Program:TestInlinedCondition(struct):int\r\n; Emitting BLENDED_CODE for X64 CPU with SSE2\r\n; optimized code\r\n; rsp based frame\r\n; partially interruptible\r\n; Final local variable assignments\r\n;\r\n;* V00 arg0         [V00    ] (  0,   0  )  struct ( 8) zero-ref   \r\n;  V01 tmp0         [V01,T02] (  3,   2  )     int  ->  rax        \r\n;  V02 tmp1         [V02,T00] (  2,   4  )    bool  ->  rax        \r\n;  V03 tmp2         [V03,T01] (  2,   2  )     int  ->  rcx         V00.Length(offs=0x00) P-INDEP\r\n;# V04 OutArgs      [V04    ] (  1,   1  )  lclBlk ( 0) [rsp+0x00]  \r\n;\r\n; Lcl frame size = 0\r\n\r\nG_M27977_IG01:\r\n\r\nG_M27977_IG02:\r\n       83F90F               cmp      ecx, 15\r\n       0F9DC0               setge    al\r\n       0FB6C0               movzx    rax, al\r\n       85C0                 test     eax, eax\r\n       7507                 jne      SHORT G_M27977_IG03\r\n       B805000000           mov      eax, 5\r\n       EB05                 jmp      SHORT G_M27977_IG04\r\nG_M27977_IG03:\r\n       B807000000           mov      eax, 7\r\n_M27977_IG04:\r\n       C3                   ret      \r\n; Total bytes of code 26, prolog size 0 for method CoreClrTest.Program:TestInlinedCondition(struct):int\r\n; ============================================================\r\n```\r\n\r\nlooks like that boolean param survived the inlining process and got its own representation in assembly."}}