digitalmars.D.bugs - [Issue 16743] New: Intrinsic recognition sometimes fails if a
- via Digitalmars-d-bugs (46/46) Nov 23 2016 https://issues.dlang.org/show_bug.cgi?id=16743
https://issues.dlang.org/show_bug.cgi?id=16743 Issue ID: 16743 Summary: Intrinsic recognition sometimes fails if a software implementation is available Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: thomas.bockman gmail.com core.bitop.bsr() is supposed to be an intrinsic, but often DMD (master) uses the function body instead. GDC and LDC do not appear to be affected. This *sometimes* works on -m64, but not on -m32: module app; import core.bitop; int main(string[] args) { return bsf(~cast(size_t) args.length); } But, if I remove the cast it fails on -m64, too: module app; import core.bitop; int main(string[] args) { return bsf(~args.length); } The uint overload never works for me on -m64, even though all it does (according to the druntime source code) is forward to the ulong one: module app; import core.bitop; int main(string[] args) { return bsf(~cast(uint) args.length); } Omitting the bitwise complement also breaks the bsf() intrinsic: module app; import core.bitop; int main(string[] args) { return bsf(cast(size_t) args.length); } The bsr() intrinsic is similarly fragile. My wild guess is that DMD's inliner is sometimes running before the intrinsic detection? The intrinsic works consistently if druntime is recompiled with the function body removed. --
Nov 23 2016