Ignore:
Timestamp:
Dec 16, 2021, 3:30:22 PM (3 years ago)
Author:
[email protected]
Message:

Use arm64's fmax/fmin instructions in Wasm
https://bugs.webkit.org/show_bug.cgi?id=234367

Reviewed by Keith Miller.

This patch adds support in B3 for FMax and FMin. We use this for Wasm's f32/64
min/max operations. On arm64, we select the arm64 fmin/fmax instructions
for these B3 opcodes. On x86, we lower these to control flow to calculate the
result inside of lower macros.

This speeds up Wasm programs that make heavy usage of min/max.

  • assembler/MacroAssemblerARM64.h:

(JSC::MacroAssemblerARM64::floatMax):
(JSC::MacroAssemblerARM64::floatMin):
(JSC::MacroAssemblerARM64::doubleMax):
(JSC::MacroAssemblerARM64::doubleMin):

  • b3/B3Common.h:

(JSC::B3::fMax):
(JSC::B3::fMin):

  • b3/B3ConstDoubleValue.cpp:

(JSC::B3::ConstDoubleValue::fMinConstant const):
(JSC::B3::ConstDoubleValue::fMaxConstant const):

  • b3/B3ConstDoubleValue.h:
  • b3/B3ConstFloatValue.cpp:

(JSC::B3::ConstFloatValue::fMinConstant const):
(JSC::B3::ConstFloatValue::fMaxConstant const):

  • b3/B3ConstFloatValue.h:
  • b3/B3LowerMacros.cpp:
  • b3/B3LowerToAir.cpp:
  • b3/B3Opcode.cpp:

(WTF::printInternal):

  • b3/B3Opcode.h:
  • b3/B3ReduceStrength.cpp:
  • b3/B3Validate.cpp:
  • b3/B3Value.cpp:

(JSC::B3::Value::fMinConstant const):
(JSC::B3::Value::fMaxConstant const):
(JSC::B3::Value::effects const):
(JSC::B3::Value::key const):
(JSC::B3::Value::typeFor):

  • b3/B3Value.h:
  • b3/B3ValueInlines.h:
  • b3/B3ValueKey.cpp:

(JSC::B3::ValueKey::materialize const):

  • b3/air/AirOpcode.opcodes:
  • b3/testb3.h:
  • b3/testb3_1.cpp:

(run):

  • b3/testb3_7.cpp:

(testFMaxMin):
(testFloatMaxMin):
(testDoubleMaxMin):

  • wasm/WasmAirIRGenerator.cpp:

(JSC::Wasm::AirIRGenerator::addFloatingPointMinOrMax):
(JSC::Wasm::AirIRGenerator::addOp<OpType::F32Min>):

  • wasm/wasm.json:
File:
1 edited

Legend:

Unmodified
Added
Removed
Note: See TracChangeset for help on using the changeset viewer.