Skip to content

Optimize More Opcode Types #274

@Geotale

Description

@Geotale

Disregarding adding potentially new type flags, currently only add, subtract, multiply, and divide are optimized right now. Modulo, round, and other blocks can definitely be optimized as well, probably when it's certain regressions have been minimized
From what I can currently tell (although there may be things I've missed or gotten incorrect):

  • X random Y:
    • canBeNaN: Any input is negative infinity
    • canBeZero: Any input is any zero, or their signs don't match
    • canBeNegZero: Either input is negative 0
    • canBePos: Any positive inputs
    • canBeNeg: Any negative inputs
    • canBeInfinity: Any input is positive infinity
    • canBeNegInfinity: Both inputs are negative infinity
  • X mod Y:
    • canBeNaN: Any inputs with any zero on the RHS, or infinity on the LHS
    • canBeZero: Any positive or positive zero LHS (checked: Negative inputs, when an exact multiple, return -0, not 0)
    • canBeNegZero: Any negative or negative 0 LHS
    • canBePos: Any positive RHS
    • canBeNeg: Any negative RHS
    • canBeInfinity: false
    • canBeNegInfinity: false
  • round X:
    • canBeNaN: false
    • canBeZero: Any positive or positive 0 input
    • canBeNegZero: Any negative or negative 0 input
    • canBePos: Any positive input
    • canBeNeg: Any negative input
    • canBeInfinity: Positive infinity input (checked: maximum finite float does not round up)
    • canBeNegInfinity: Negative infinity input (checked: maximum negative finite float does not round up)
  • abs X:
    • canBeNaN: false
    • canBeZero: Any zero input
    • canBeNegZero: false
    • canBePos: Any nonzero input
    • canBeNeg: false
    • canBeInfinity: Any infinite input
    • canBeNegInfinity: false
  • floor X:
    • canBeNaN: false
    • canBeZero: Any positive or 0 input
    • canBeNegZero: Negative 0 input
    • canBePos: Any positive input
    • canBeNeg: Any negative input
    • canBeInfinity: Positive infinity input
    • canBeNegInfinity: Negative infinity input
  • ceiling X:
    • canBeNaN: false
    • canBeZero: Positive 0 input
    • canBeNegZero: Any negative or negative 0 input
    • canBePos: Any positive input
    • canBeNeg: any negative input
    • canBeInfinity: Positive infinity input
    • canBeNegInfinity: Negative infinity input
  • sqrt X:
    • canBeNaN: Any negative input
    • canBeZero: Positive 0 input
    • canBeNegZero: Negative 0 input
    • canBePos: Any positive input
    • canBeNeg: false
    • canBeInfinity: Positive infinity input
    • canBeNegInfinity: false
  • sin X:
    • canBeNaN: Any infinite input
    • canBeZero: true
    • canBeNegZero: true
    • canBePos: true
    • canBeNeg: true
    • canBeInfinity: false
    • canBeNegInfinity: false
  • cos X: (same as sin X)
    • canBeNaN: Any infinite input
    • canBeZero: true
    • canBeNegZero: true
    • canBePos: true
    • canBeNeg: true
    • canBeInfinity: false
    • canBeNegInfinity: false
  • tan X:
    • canBeNaN: Any infinite input
    • canBeZero: true
    • canBeNegZero: true
    • canBePos: true
    • canBeNeg: true
    • canBeInfinity: true
    • canBeNegInfinity: true
  • asin X:
    • canBeNaN: true
    • canBeZero: Positive zero input (checked: minimum positive input does not return 0)
    • canBeNegZero: Negative zero input (checked: minimum negative input does not return -0)
    • canBePos: Any positive input
    • canBeNeg: Any negative input
    • canBeInfinity: false
    • canBeNegInfinity: false
  • acos X: (NUMBER_POS_REAL | NUMBER_NAN)
    • canBeNaN: true
    • canBeZero: true
    • canBeNegZero: false
    • canBePos: true
    • canBeNeg: false
    • canBeInfinity: false
    • canBeNegInfinity: false
  • atan X:
    • canBeNaN: false
    • canBeZero: Positive zero input (checked: minimum positive input does not return 0)
    • canBeNegZero: Negative zero input (checked: minimum negative input does not return -0)
    • canBePos: Any positive input
    • canBeNeg: Any negative input
    • canBeInfinity: false
    • canBeNegInfinity: false
  • ln X:
    • canBeNaN: Any negative input
    • canBeZero: true
    • canBeNegZero: false
    • canBePos: true
    • canBeNeg: true
    • canBeInfinity: Any infinite input
    • canBeNegInfinity: Any zero input
  • log X: (same as ln X)
    • canBeNaN: Any negative input
    • canBeZero: true
    • canBeNegZero: false
    • canBePos: true
    • canBeNeg: true
    • canBeInfinity: Any infinite input
    • canBeNegInfinity: Any zero input
  • e ^ X:
    • canBeNaN: false
    • canBeZero: Any negative input (checked: negatively large enough non-infinite value returns 0)
    • canBeNegZero: false
    • canBePos: true
    • canBeNeg: false
    • canBeInfinity: Any positive input (checked: positively large enough non-infinite value returns Infinity)
    • canBeNegInfinity: false
  • 10 ^ X: (same as e ^ X)
    • canBeNaN: false
    • canBeZero: Any negative input
    • canBeNegZero: false
    • canBePos: true
    • canBeNeg: false
    • canBeInfinity: Any positive input
    • canBeNegInfinity: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceIdeas for improving performance

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions