Skip to content

UPSTREAM PR #30829: Drop redundant/confusing NULL check#666

Open
loci-dev wants to merge 1 commit into
mainfrom
loci/pr-30829-mlkem-i2d-polish
Open

UPSTREAM PR #30829: Drop redundant/confusing NULL check#666
loci-dev wants to merge 1 commit into
mainfrom
loci/pr-30829-mlkem-i2d-polish

Conversation

@loci-dev
Copy link
Copy Markdown

Note

Source pull request: openssl/openssl#30829

  • The pointer cannot be NULL, and test only confuses static analysers.

  • Incidentally, undo clang auto-format of displayed tables in the same file.

Checklist
  • documentation is added or updated
  • tests are added or updated

- The pointer cannot be NULL, and test only confuses statis analysers.

- Incidentally, undo clang auto-format of  displayed tables in the same file.
@loci-review
Copy link
Copy Markdown

loci-review Bot commented Apr 15, 2026

Overview

Analysis of 20,082 functions across three binaries shows minimal performance impact. Only 2 functions modified (0.01%), with 1 showing measurable improvement and no regressions detected.

Binaries analyzed:

  • libcrypto.so: 253,391.34 nJ (0.0% change)
  • libssl.so: 61,823.23 nJ (0.0% change)
  • openssl: 42,314.91 nJ (0.0% change)

Function Analysis

ossl_ml_kem_i2d_pubkey (libcrypto.so)

  • Response time: 2,196ns → 2,165ns (-31ns, -1.4%)
  • Throughput time: 161ns → 130ns (-31ns, -19.2%)

Source code change: Commit d698a00 removed a redundant NULL check on the out parameter before dereferencing it. The check was confusing since out (typed as unsigned char **) must be a valid pointer for the function to work correctly. Removing this unnecessary conditional eliminated one branch and enabled better compiler optimization—the critical success path block improved from 36.9ns to 15.24ns through better instruction scheduling, paired register operations (stp/ldp), and expanded register allocation (x21, x22).

The 19.2% throughput improvement is fully explained by the branch elimination and resulting compiler optimizations. This code quality improvement clarified the function's preconditions while yielding measurable performance benefits. The function is part of ML-KEM post-quantum cryptography encoding, currently moderate-priority but increasing in importance as quantum-resistant algorithms see wider adoption.

💬 Questions? Tag @loci-dev

@loci-dev loci-dev force-pushed the main branch 4 times, most recently from b5b7577 to a9c9e17 Compare April 23, 2026 03:41
@loci-dev loci-dev force-pushed the main branch 4 times, most recently from 421b135 to 770bf14 Compare April 28, 2026 03:44
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.

1 participant