• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
      • X86isa
        • Program-execution
        • Sdm-instruction-set-summary
        • Tlb
        • Running-linux
        • Introduction
        • Asmtest
        • X86isa-build-instructions
        • Publications
        • Contributors
        • Machine
          • X86isa-state
          • Syscalls
          • Cpuid
          • Linear-memory
          • Rflag-specifications
          • Characterizing-undefined-behavior
          • Top-level-memory
          • App-view
          • X86-decoder
          • Physical-memory
          • Decoding-and-spec-utils
          • Instructions
            • Two-byte-opcodes
            • One-byte-opcodes
            • Fp-opcodes
            • Instruction-semantic-functions
              • Sar-spec
              • Shr-spec
              • Sal/shl-spec
              • Rol-spec
              • Ror-spec
              • Rcl-spec
              • Rcr-spec
              • Simd-sub-spec
                • Simd-add-spec
                • Imul-spec
                • Mul-spec
                • Idiv-spec
                • Div-spec
                • Shrd-spec
                • Shld-spec
                • Gpr-arith/logic-spec
                • Shrx-spec
                • Shlx-spec
                • Sarx-spec
                • Floating-point-specifications
              • X86-illegal-instruction
              • Implemented-opcodes
              • Opcode-maps
              • X86-general-protection
              • X86-device-not-available
              • X86-step-unimplemented
              • Privileged-opcodes
              • Three-byte-opcodes
            • Register-readers-and-writers
            • X86-modes
            • Segmentation
            • Other-non-deterministic-computations
            • Environment
            • Paging
          • Implemented-opcodes
          • To-do
          • Proof-utilities
          • Peripherals
          • Model-validation
          • Modelcalls
          • Concrete-simulation-examples
          • Utils
          • Debugging-code-proofs
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Instruction-semantic-functions

    Simd-sub-spec

    Specification for the SIMD subtraction instructions.

    Signature
    (simd-sub-spec total-size chunk-size x y) → result
    Arguments
    total-size — Guard (natp total-size).
    chunk-size — Guard (posp chunk-size).
    x — Guard (unsigned-byte-p total-size x).
    y — Guard (unsigned-byte-p total-size y).
    Returns
    result — Type (unsigned-byte-p total-size result), given the guard.

    This is for the (V)PSUBB/(V)PSUBW/(V)PSUBD/(V)PSUBQ instructions.

    Given x and y of size total-size in bits, we perform a subtraction on each chunk of size chunk-size in bits, independently from the other chunks, keeping the low chunk-size bits of each result, and putting the resulting chunks together, in the same order, to obtain the final result of size total-size. This kind of operation is illustrated in Intel Manual Volume 1 Figure 9-4 (Dec 2023).

    The total-size must be a multiple of chunk-size. For instance, for the VEX form of VPSUBW, total-size is 128 and chunk-size is 16.

    Definitions and Theorems

    Function: simd-sub-spec

    (defun simd-sub-spec (total-size chunk-size x y)
      (declare (xargs :guard (and (natp total-size)
                                  (posp chunk-size)
                                  (unsigned-byte-p total-size x)
                                  (unsigned-byte-p total-size y))))
      (declare (xargs :guard (integerp (/ total-size chunk-size))))
      (let ((__function__ 'simd-sub-spec))
        (declare (ignorable __function__))
        (b* (((when (zp total-size)) 0)
             ((unless (mbt (posp chunk-size))) 0)
             (x-lo (loghead chunk-size x))
             (y-lo (loghead chunk-size y))
             (result-lo (loghead chunk-size (- x-lo y-lo)))
             (x-hi (logtail chunk-size x))
             (y-hi (logtail chunk-size y))
             (result-hi (simd-sub-spec (- total-size chunk-size)
                                       chunk-size x-hi y-hi)))
          (logapp chunk-size result-lo result-hi))))

    Theorem: return-type-of-simd-sub-spec

    (defthm return-type-of-simd-sub-spec
      (implies
           (and (natp total-size)
                (posp chunk-size)
                (unsigned-byte-p total-size x)
                (unsigned-byte-p total-size y)
                (integerp (binary-* total-size (unary-/ chunk-size))))
           (b* ((result (simd-sub-spec total-size chunk-size x y)))
             (unsigned-byte-p total-size result)))
      :rule-classes :rewrite)