Skip to content

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