Bug 16743 – Intrinsic recognition sometimes fails if a software implementation is available

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-11-23T19:55:02Z
Last change time
2019-05-09T02:30:52Z
Keywords
pull
Assigned to
No Owner
Creator
thomas.bockman

Comments

Comment #0 by thomas.bockman — 2016-11-23T19:55:02Z
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.
Comment #1 by bugzilla — 2016-11-24T02:19:41Z
Comment #2 by github-bugzilla — 2016-11-25T13:51:02Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/a1d1204abce198cce00e41cfd67039eec3d2e866 fix Issue 16743 - Intrinsic recognition sometimes fails if a software implementation is available https://github.com/dlang/dmd/commit/0e4152265a2e16ca49ea8ea34a82109ce6c59cbc Merge pull request #6278 from WalterBright/fix16743 fix Issue 16743 - Intrinsic recognition sometimes fails if a software…
Comment #3 by github-bugzilla — 2016-11-25T14:55:40Z
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/7f90cdce59cd422224172327fd7ddb6ce3f9eac6 fix Issue 16743 - Intrinsic recognition sometimes fails if a software implementation is available https://github.com/dlang/druntime/commit/dc622e5e2e5485d6f12433500dcffcda5b45c930 Merge pull request #1695 from WalterBright/fix16743 fix Issue 16743 - Intrinsic recognition sometimes fails if a software…
Comment #4 by thomas.bockman — 2016-11-25T22:08:05Z
I have tested and can confirm that this is fixed in master. Thanks.
Comment #5 by github-bugzilla — 2016-12-27T13:11:06Z
Commits pushed to scope at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/7f90cdce59cd422224172327fd7ddb6ce3f9eac6 fix Issue 16743 - Intrinsic recognition sometimes fails if a software implementation is available https://github.com/dlang/druntime/commit/dc622e5e2e5485d6f12433500dcffcda5b45c930 Merge pull request #1695 from WalterBright/fix16743
Comment #6 by github-bugzilla — 2016-12-27T14:41:27Z
Commits pushed to scope at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/a1d1204abce198cce00e41cfd67039eec3d2e866 fix Issue 16743 - Intrinsic recognition sometimes fails if a software implementation is available https://github.com/dlang/dmd/commit/0e4152265a2e16ca49ea8ea34a82109ce6c59cbc Merge pull request #6278 from WalterBright/fix16743
Comment #7 by github-bugzilla — 2017-01-07T03:02:02Z
Commits pushed to stable at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/7f90cdce59cd422224172327fd7ddb6ce3f9eac6 fix Issue 16743 - Intrinsic recognition sometimes fails if a software implementation is available https://github.com/dlang/druntime/commit/dc622e5e2e5485d6f12433500dcffcda5b45c930 Merge pull request #1695 from WalterBright/fix16743
Comment #8 by github-bugzilla — 2017-01-16T23:24:31Z
Commits pushed to newCTFE at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/7f90cdce59cd422224172327fd7ddb6ce3f9eac6 fix Issue 16743 - Intrinsic recognition sometimes fails if a software implementation is available https://github.com/dlang/druntime/commit/dc622e5e2e5485d6f12433500dcffcda5b45c930 Merge pull request #1695 from WalterBright/fix16743
Comment #9 by github-bugzilla — 2017-01-16T23:25:29Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/a1d1204abce198cce00e41cfd67039eec3d2e866 fix Issue 16743 - Intrinsic recognition sometimes fails if a software implementation is available https://github.com/dlang/dmd/commit/0e4152265a2e16ca49ea8ea34a82109ce6c59cbc Merge pull request #6278 from WalterBright/fix16743