On Tue, Jan 25, 2022 at 10:41:35PM +0000, Elronnd via Digitalmars-d-learn wrote: > On Tuesday, 25 January 2022 at 22:33:37 UTC, H. S. Teoh wrote: > > interesting because idivl is known to be one of the slower > > instructions, but gdc nevertheless considered it not worthwhile to > > replace it, whereas ldc seems obsessed about avoid idivl at all > > costs. > > Interesting indeed. Two remarks: > > 1. Actual performance cost of div depends a lot on hardware. IIRC on > my old intel laptop it's like 40-60 cycles; on my newer amd chip it's > more like 20; on my mac it's ~10. GCC may be assuming newer hardware > than llvm. Could be worth popping on a -march=native -mtune=native. > Also could depend on how many ports can do divs; i.e. how many of them > you can have running at a time.
I tried `ldc2 -mcpu=native` but that did not significantly change the performance. > 2. LLVM is more aggressive wrt certain optimizations than gcc, by > default. Though I don't know how relevant that is at -O3. Yeah, I've noted in the past that LDC seems to be pretty aggressive with inlining / loop unrolling, whereas GDC has a thing for vectorization and SIMD/XMM usage. The exact outcomes are a toss-up, though. Sometimes LDC wins, sometimes GDC wins. Depends on what exactly the code is doing. T -- "Outlook not so good." That magic 8-ball knows everything! I'll ask about Exchange Server next. -- (Stolen from the net)