Skip to content
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

pp_(i_)negate: TARGMY & favour-IV/NV optimizations #21442

Merged
merged 3 commits into from Sep 7, 2023

Conversation

richardleach
Copy link
Contributor

The negate and i_negate functions are modified in a series of commits such that they:

  • Support the generic TARGMY optimization, such that op_targ points directly to the SV to be assigned into, rather than assigning into a PADTMP for subsequent assignment by a different OP.
  • Are RC-stack aware.
  • Don't always call S_negate_string without first checking if the argument even looks like a string.

@iabyn
Copy link
Contributor

iabyn commented Sep 1, 2023 via email

@richardleach
Copy link
Contributor Author

Would you be able to hold off and rebase this once my work is merged?

Yeah, that's no problem.

It was still useful for me to get familiar with the new macros.

@richardleach richardleach added the do not merge Don't merge this PR, at least for now label Sep 1, 2023
@richardleach richardleach changed the title pp_(i_)negate: optimizations & RC stack support pp_(i_)negate: TARGMY & favour-IV/NV optimizations Sep 5, 2023
@richardleach
Copy link
Contributor Author

Just running tests locally before pushing rebased commits. This PR will now do the following for negate and i_negate:

  • Support the generic TARGMY optimization, such that op_targ points directly to the SV to be assigned into, rather than assigning into a PADTMP for subsequent assignment by a different OP.
  • Don't always call S_negate_string without first checking if the argument even looks like a string.

@richardleach richardleach removed the do not merge Don't merge this PR, at least for now label Sep 5, 2023
pp.c Outdated Show resolved Hide resolved
Adds a case in `S_negate_string` to allow for TARG==sv, which then
means that the `pp_negate` and `pp_i_negate` OPs can support the
TARGMY optimization
This mostly means using the existing machinery in regen/, but also not
bothering to replace *PL_stack_sp when (targ == sv), as that would
effectively be a busywork no-op.
Arguably it will be more common for users to want to negate an IV or NV,
rather than a PV. Prior to this commit, `S_negate_string` was always called
at the start of the OP and, if the target wasn't `SvPOKp`, that function
just immediately returned. This commit moves the `SvPOKp` check into the
`pp_` functions to avoid needless function calls.
@richardleach richardleach merged commit c904517 into Perl:blead Sep 7, 2023
28 checks passed
@richardleach richardleach deleted the hydahy/TARGMYnegate branch September 7, 2023 21:43
@mauke mauke mentioned this pull request Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants