Repository navigation
Closed
Labels
approved: trusted-baseOwner-approved trusted-base change (owner applies only)faster-compcertPart of the faster-compcert projectneeds-approvalBlocked until the trusted-base change is approvedtier-2: trusted-baseChanges semantics/axioms/trusted code; requires the approval protocol
Description
Tier 1, no trusted-base change. The new Asm instructions need semantics, and those are reviewed like other Asm instructions.
Problem
CompCert always emits movsd mem,%t; addsd %t,%x. GCC emits addsd mem,%x. This costs extra instructions and registers, and therefore spills in floating-point-heavy loops.
Evidence (assembly surgery)
| benchmark | change | effect |
|---|---|---|
| nbody | fold 9 loads into memory operands in the inner loop | 106 → 95 ms (−10%) |
| aes | xorl mem,%r |
85.2 → 82.5 ms (−3%) |
Proposed approach
An RTL operator that reads memory would break the invariants Deadcode, CSE and ValueAnalysis rely on: they track memory only through Iload/Istore/builtins. Better options:
- fuse
load; opat the Linear/Mach → Asm boundary, in a verified peephole. The x86sel agent found that a straightforward Asmgen peephole conflicts withAsmgenproof0'stransl_instr_tail/is_tailstructure, so this needs a dedicated pass with its own simulation, e.g. on Mach or Linear; - or fuse in a new Linear-level pass that introduces
Lop_meminstructions, with Stacking and Asmgen support.
Acceptance criteria
- Complete proofs: no
Admitted,admitor newAxiom.check_axioms.shadds at most flag or validated-oracle parameters. make proofsucceeds on x86_64, x86_32, aarch64, arm, powerpc and rv64. Stubs on non-x86 targets are fine.make -C test all testpasses.- Benchmarks:
- full
test/csuite, 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).
- full
- Compile-time and code-size impact reported.
- New behaviour can be turned off with a
-fno-*flag.
Metadata
Metadata
Assignees
Labels
approved: trusted-baseOwner-approved trusted-base change (owner applies only)faster-compcertPart of the faster-compcert projectneeds-approvalBlocked until the trusted-base change is approvedtier-2: trusted-baseChanges semantics/axioms/trusted code; requires the approval protocol
Activity
AananthV commentedon Oct 22, 2026
Trusted-base proposal for #5 (load-op memory operands)
This item needs new x86 Asm instructions with memory operands. CompCert's x86 Asm model has memory forms only for moves (
Pmovsd_fm,Pmovl_rm, …).x86/Asm.vis on the trusted-path list in #1, so this is a Tier 2 change and needs owner approval before implementation.Assumption: exact text (proposed additions to
x86/Asm.v)New constructors. A first, minimal set covers what was measured (nbody, aes):
Semantics, using a helper modelled on the existing
exec_load:Printer (
x86/TargetPrinter.ml, also trusted):addsd %a, %freg,addl %a, %ireg32, etc., with the existingaddressingprinter.Justification
Intel SDM Vol. 2:
xmm1, xmm2/m64.r32, r/m32(opcodes 03 /r, 33 /r, 23 /r, 0B /r).Each instruction reads the operand from memory and combines it with the register exactly as the register-register form does. The register-register forms are already modelled:
Paddd_ff→Val.addf,Pxorl_rr→Val.xorwithnextinstr_nf.Faithfulness argument
Pmovsd_fm/Pmovl_rmloads: the sameMem.loadvwith the same chunk. If the model can't perform the load (invalid or misaligned per CompCert's chunk alignment), the step isStuck, so no verified execution relies on it.movaps, which are not used here. So the model is stricter than the hardware, which is the safe direction.nextinstr_nf), likePxorl_rr.nextinstr), likePaddd_ff.movsd mem, tmp; addsd tmp, rd, except that no temporary register is clobbered.Blast radius
x86/Asm.vand printer cases. No change to existing instructions, the memory model, or other targets.Print Assumptions: no new axioms.load chunk a -> t; op rd rd t(withtdead afterwards) into the load-op form.Asmgenproof0'stransl_instr_tail/is_tail, so this is likely a small Mach-level pass with its own simulation.Opt-in story
-fload-op, off by default, per Protocol: approval process for trusted-base (Tier 2) changes #1.Validation plan
-fload-op.Payoff (measured by asm surgery, REPORT.md §1.3)
xorl memPolyBench inner loops (e.g. gemm:
mulsd (%r9,%rdx),addsd (%rdi,%rdx)in gcc -O1) would also benefit.Requesting owner approval: apply
approved: trusted-baseto proceed, or comment with changes.[-]x86: load-op memory operands (addsd mem,%x)[/-][+]x86: load-op memory operands (addsd mem,%x) [needs trusted-base approval][/+]AananthV commentedon Oct 22, 2026
Owner approval recorded (2026-10-22): the owner approved this proposal in chat ("LGTM for memory-operand arithmetic (#5)"). The approval covers exactly the proposal above:
Paddd_fm/Psubd_fm/Pmuld_fm/Pdivd_fm/Paddl_rm/Pxorl_rm/Pandl_rm/Porl_rm;exec_loadopsemantics;-fload-opoff by default.Per Protocol: approval process for trusted-base (Tier 2) changes #1, the
approved: trusted-baselabel is left for the owner to apply. Any change to the trusted definitions beyond this needs re-approval. Implementation is starting on branchissue-5-load-op.Add Loadop: verified fusion of loads into x86 arithmetic memory operands
faster-compcert: trusted-base ledger, asm_difftest, report on Loadop …
Add Loadop: verified fusion of loads into x86 arithmetic memory operands