digitalmars.D.learn - Does the compiler inline the predicate functions to
- tipdbmp (4/4) Mar 18 2018 I can't read assembly but it seems to me that it doesn't:
- Radu (2/6) Mar 18 2018 add "-O3" also to the compiler switches.
- Stefan Koch (7/11) Mar 18 2018 Correct it does not get in-lined.
- David Nadlinger (6/17) Mar 18 2018 I believe the original poster was asking about the *predicate* to
- tipdbmp (4/8) Mar 19 2018 I only seem to get assembly on d.godbolt.org, even with the
- Seb (6/14) Mar 19 2018 DMD has a -inline flag to enable inlining - though LDC is a lot
- Johan Engelen (4/9) Mar 19 2018 On d.godbolt.org, you can get LLVM IR with a trick: use
I can't read assembly but it seems to me that it doesn't: https://godbolt.org/g/PCsnPT I think C++'s sort can take a "function object" that can get inlined.
Mar 18 2018
On Sunday, 18 March 2018 at 12:59:06 UTC, tipdbmp wrote:I can't read assembly but it seems to me that it doesn't: https://godbolt.org/g/PCsnPT I think C++'s sort can take a "function object" that can get inlined.add "-O3" also to the compiler switches.
Mar 18 2018
On Sunday, 18 March 2018 at 12:59:06 UTC, tipdbmp wrote:I can't read assembly but it seems to me that it doesn't: https://godbolt.org/g/PCsnPT I think C++'s sort can take a "function object" that can get inlined.Correct it does not get in-lined. Even with -O3 it does not. The reason is that the code the sort instantiation produces is too big for the inliner cost function. If you have a look at the the cg file produced when you specify -vcg-ast you can see that it's a massive amount of code.
Mar 18 2018
On Sunday, 18 March 2018 at 14:15:37 UTC, Stefan Koch wrote:On Sunday, 18 March 2018 at 12:59:06 UTC, tipdbmp wrote:I believe the original poster was asking about the *predicate* to sort, which is indeed inlined with optimizations on. ( tipdbmp: The string gets turned into the function _D3std10functional__T9binaryFunVAyaa5_61203c2062VQra1_61VQza1_62Z__TQBvTiTi QCdFNaNbNiNfKiKiZb. No references to it remain with -O3; the LLVM IR obtained with -output-ll might be easier to read than assembly.) — DavidI can't read assembly but it seems to me that it doesn't: https://godbolt.org/g/PCsnPT I think C++'s sort can take a "function object" that can get inlined.Correct it does not get in-lined. Even with -O3 it does not. The reason is that the code the sort instantiation produces is too big for the inliner cost function. If you have a look at the the cg file produced when you specify -vcg-ast you can see that it's a massive amount of code.
Mar 18 2018
( tipdbmp: The string gets turned into the function _D3std10functional__T9binaryFunVAyaa5_61203c2062VQra1_61VQza1_62Z__TQBvTiTi QCdFNaNbNiNfKiKiZb. No references to it remain with -O3; the LLVM IR obtained with -output-ll might be easier to read than assembly.)I see. It seems that ldc 1.8.0 with "-release -O2|3" inlines it, but dmd 2.079.0 with "-release" (no -O option?) does not.the LLVM IR obtained with -output-ll might be easier to read than assembly.)I only seem to get assembly on d.godbolt.org, even with the -output-ll option.
Mar 19 2018
On Monday, 19 March 2018 at 12:45:58 UTC, tipdbmp wrote:DMD has a -inline flag to enable inlining - though LDC is a lot better in optimization than DMD and thus typically used for anything performance related.( tipdbmp: The string gets turned into the function _D3std10functional__T9binaryFunVAyaa5_61203c2062VQra1_61VQza1_62Z__TQBvTiTi QCdFNaNbNiNfKiKiZb. No references to it remain with -O3; the LLVM IR obtained with -output-ll might be easier to read than assembly.)I see. It seems that ldc 1.8.0 with "-release -O2|3" inlines it, but dmd 2.079.0 with "-release" (no -O option?) does not.You can get IR on run.dlang.io by simply selecting LDC and hitting the IR button.the LLVM IR obtained with -output-ll might be easier to read than assembly.)I only seem to get assembly on d.godbolt.org, even with the -output-ll option.
Mar 19 2018
On Monday, 19 March 2018 at 12:45:58 UTC, tipdbmp wrote:On d.godbolt.org, you can get LLVM IR with a trick: use `-output-s=false -output-ll`. -Johanthe LLVM IR obtained with -output-ll might be easier to read than assembly.)I only seem to get assembly on d.godbolt.org, even with the -output-ll option.
Mar 19 2018