MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / IsFoldableByFoldVector

Method IsFoldableByFoldVector

source/opt/instruction.cpp:801–821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

799}
800
801bool Instruction::IsFoldableByFoldVector() const {
802 const InstructionFolder& folder = context()->get_instruction_folder();
803 if (!folder.IsFoldableOpcode(opcode())) {
804 return false;
805 }
806
807 Instruction* type = context()->get_def_use_mgr()->GetDef(type_id());
808 if (!folder.IsFoldableVectorType(type)) {
809 return false;
810 }
811
812 // Even if the type of the instruction is foldable, its operands may not be
813 // foldable (e.g., comparisons of 64bit types). Check that all operand types
814 // are foldable before accepting the instruction.
815 return WhileEachInId([&folder, this](const uint32_t* op_id) {
816 Instruction* def_inst = context()->get_def_use_mgr()->GetDef(*op_id);
817 Instruction* def_inst_type =
818 context()->get_def_use_mgr()->GetDef(def_inst->type_id());
819 return folder.IsFoldableVectorType(def_inst_type);
820 });
821}
822
823bool Instruction::IsFloatingPointFoldingAllowed() const {
824 // TODO: Add the rules for kernels. For now it will be pessimistic.

Callers 1

Calls 5

IsFoldableOpcodeMethod · 0.80
IsFoldableVectorTypeMethod · 0.80
GetDefMethod · 0.45
get_def_use_mgrMethod · 0.45
type_idMethod · 0.45

Tested by

no test coverage detected