Skip to content

x86: small code-generation fixes (stack-array addressing, byte-load zero-extension, byte-field extraction) #6

Closed

Description

@AananthV

Tier 1, no trusted-base change (new Asm instructions, if any, are reviewed as usual). A batch of small x86 code-generation fixes, each measured by assembly surgery.

item benchmark effect
Stack arrays use ofs(%rsp,idx,scale), so leaq 24(%rsp),%rX is not recomputed before every access sha1 57.6 → 53.5 ms (−7%)
Zero-extending byte loads into a 64-bit register: movzbl producing a Vlong, removing the remaining movl %r,%r after byte loads. Needs a new memory chunk or a Mach-level fusion; the current fused ops cover shifts and masks only siphash24 8 → 5 per word done; all 8 → 0.0824 vs 0.0837 s
Byte-field extraction (x >> 8) & 0xff as movzbl %ah-style instead of movq/shrl/andl/movl vmach part of the remaining ~9%
Rotate recognition in remaining patterns (shld) sha3 small

Each fix: selection/Asmgen change + proof, measured alone and combined.

Acceptance criteria

  • Complete proofs: no Admitted, admit or new Axiom. check_axioms.sh adds at most flag or validated-oracle parameters.
  • make proof succeeds on x86_64, x86_32, aarch64, arm, powerpc and rv64. Stubs on non-x86 targets are fine.
  • make -C test all test passes.
  • Benchmarks:
    • full test/c suite, plus the larger programs once that evaluation issue lands;
    • no regression beyond noise;
    • the change is also measured combined with all the passes already on master, using the -fno-* flags for ablation (see REPORT.md §2.4).
  • Compile-time and code-size impact reported.
  • New behaviour can be turned off with a -fno-* flag.

Activity

  1. added
    faster-compcert
    tier-1: verified
    on Oct 21, 2026
  2. AananthV commented on Oct 22, 2026

    @AananthV
    OwnerAuthor

    Split by the protocol (#1):

    • Stack-array addressing (ofs(%rsp,idx,scale), sha1 −7%) is instruction selection only, so it stays Tier 1 and can proceed.
    • Zero-extending byte loads into a 64-bit register and movzbl %ah-style byte-field extraction need new Asm instructions/semantics in x86/Asm.v, so they are Tier 2. They will get a proposal of their own (like the one on x86: load-op memory operands (addsd mem,%x) [needs trusted-base approval] #5) once the Tier 1 part is done.
  3. AananthV commented on Oct 22, 2026

    @AananthV
    OwnerAuthor

    Additional Tier 1 item found during #7: 64-bit rotate by 1 is not recognised. In sha3's keccakf, ROTL64(x,1) compiles to lea/mov/shr/or (4 instructions) instead of rolq, 5 times per round. As with the 32-bit case fixed earlier, x<<1 has already become a lea (Oleal) before orl can match the shl/shr pair. The fix belongs in x86/SelectLong.vp (orl should use an is_shllimm-style recognizer that also accepts the scaled lea form), with its proof in SelectLongproof.v. This is selection only, so Tier 1.

  4. AananthV commented on Oct 22, 2026

    @AananthV
    OwnerAuthor

    Tier 1 part (stack-array addressing, 64-bit rotate by 1) in progress on branch issue-6-x86-codegen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    faster-compcerttier-1: verified

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions