| 799 | } |
| 800 | |
| 801 | bool 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 | |
| 823 | bool Instruction::IsFloatingPointFoldingAllowed() const { |
| 824 | // TODO: Add the rules for kernels. For now it will be pessimistic. |
no test coverage detected