summaryrefslogtreecommitdiff
path: root/source/opt/fold.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/opt/fold.cpp')
-rw-r--r--source/opt/fold.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/opt/fold.cpp b/source/opt/fold.cpp
index ab7239d9..6cc486a0 100644
--- a/source/opt/fold.cpp
+++ b/source/opt/fold.cpp
@@ -41,11 +41,6 @@ namespace {
#define UINT32_MAX 0xffffffff /* 4294967295U */
#endif
-const ConstantFoldingRules& GetConstantFoldingRules() {
- static ConstantFoldingRules* rules = new ConstantFoldingRules();
- return *rules;
-}
-
// Returns the single-word result from performing the given unary operation on
// the operand value which is passed in as a 32-bit word.
uint32_t UnaryOperate(SpvOp opcode, uint32_t operand) {
@@ -225,6 +220,11 @@ bool FoldInstructionInternal(ir::Instruction* inst) {
} // namespace
+const ConstantFoldingRules& GetConstantFoldingRules() {
+ static ConstantFoldingRules* rules = new ConstantFoldingRules();
+ return *rules;
+}
+
// Returns the result of performing an operation on scalar constant operands.
// This function extracts the operand values as 32 bit words and returns the
// result in 32 bit word. Scalar constants with longer than 32-bit width are
@@ -612,7 +612,7 @@ ir::Instruction* FoldInstructionToConstant(
ir::IRContext* context = inst->context();
analysis::ConstantManager* const_mgr = context->get_constant_mgr();
- if (!inst->IsFoldable() &&
+ if (!inst->IsFoldableByFoldScalar() &&
!GetConstantFoldingRules().HasFoldingRule(inst->opcode())) {
return nullptr;
}
@@ -649,12 +649,12 @@ ir::Instruction* FoldInstructionToConstant(
uint32_t result_val = 0;
bool successful = false;
// If all parameters are constant, fold the instruction to a constant.
- if (!missing_constants && inst->IsFoldable()) {
+ if (!missing_constants && inst->IsFoldableByFoldScalar()) {
result_val = FoldScalars(inst->opcode(), constants);
successful = true;
}
- if (!successful && inst->IsFoldable()) {
+ if (!successful && inst->IsFoldableByFoldScalar()) {
successful = FoldIntegerOpToConstant(inst, id_map, &result_val);
}