Skip to content

Make specialization of x64 zend_safe_address() for nmemb==1 #19203

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

Merged
merged 1 commit into from
Jul 21, 2025

Conversation

nielsdos
Copy link
Member

There are typically 3 forms of calls to this function:

  1. nmemb>1, offset=0||size=0
  2. nmemb=1, size>0, offset>0
  3. nmemb>1, size>0, offset>0

This specializes the second form: it avoids the multiplication.
For clang, which has trouble with the rm constraint, it also avoids some spills in some cases.

@nielsdos nielsdos marked this pull request as draft July 21, 2025 15:06
@nielsdos nielsdos force-pushed the specialise-safe-guard branch 2 times, most recently from 8afec0d to 03e4f20 Compare July 21, 2025 15:28
There are typically 3 forms of calls to this function:
1. nmemb>1, offset=0||size=0
2. nmemb=1, size>0, offset>0
3. nmemb>1, size>0, offset>0

This specializes the second form.
@nielsdos nielsdos force-pushed the specialise-safe-guard branch from 03e4f20 to 3987ea7 Compare July 21, 2025 15:42
@nielsdos nielsdos marked this pull request as ready for review July 21, 2025 16:42
"adc $0,%1"
: "+r"(res), "+r" (m_overflow)
: "rm"(offset)
: "cc");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need this clobber hint for the other branches?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also surprised me, I think we actually do need it. I don't know why it isn't there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make sense to backport that part.

@nielsdos nielsdos merged commit c55f142 into php:master Jul 21, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy