-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-7842] Inconsistent codegen for closed ranges vs bit-manipulation #50378
Comments
@swift-ci create |
@eeckstein this is not super urgent, but will affect performance of small strings with UTF-8 support and UTF-8 validation in general (especially applicable to server-side). Do you think this could be tackled this summer? I'll update this with some other codegen oddities I see. |
A case where the range is superior to bits and compare:
|
A case where bits is very similar to range, but slightly superior (`and` being better than `sxtb` on some uArches):
|
Yes, the summer timeframe looks reasonable |
Attached foo.swift and foo.txt to demonstrate all the needed functionality for efficient UTF-8 validation byte-by-byte. It will likely be adjusted some day to use wider loads, but this gives good and relevant optimizer fodder! |
Investigating this could be a good performance starter bug too, as it's fairly self-contained. It may span conventions across both SIL and LLVM, though. |
@swift-ci update |
Please don't tag something as a Starter Bug unless you already know the basic idea of how to fix it. |
Comment by Erik Verbruggen (JIRA) So there is |
Comment by Erik Verbruggen (JIRA) Nevermind the previous question, 4.1 generates the same code. |
Comment by Erik Verbruggen (JIRA) So, how do I tell swiftc to apply optimisation to SIL, but to emit unoptimised LLVM IR? Just supplying -O will run optimisation for both. |
We should really have an |
IMO, this is something what should be handled by an LLVM peephole optimization. |
Comment by Erik Verbruggen (JIRA) For all functions, the LLVM IR is a nearly direct translation of the Swift code/SIL when disabling LLVM optimisations. So an easy observation is that not optimising I do agree with @eeckstein that the best place probably is a peephole pass, but I'll leave that to someone else as I don't have any experience in the MI layer. (If someone has an example of such a pass though, I'd be interested, just to learn about it.) |
Attachment: Download
Additional Detail from JIRA
md5: 223093f3dc3457d4c7f42d8a0e46938f
Issue Description:
ClosedRange<UInt8> demonstrates poor codegen compared to explicit bit manipulation.
The code generated for _isContinuation_bits is superior:
The text was updated successfully, but these errors were encountered: