diff --git a/src/alloy/compiler/passes/constant_propagation_pass.cc b/src/alloy/compiler/passes/constant_propagation_pass.cc index a481d18af..5804ed218 100644 --- a/src/alloy/compiler/passes/constant_propagation_pass.cc +++ b/src/alloy/compiler/passes/constant_propagation_pass.cc @@ -371,7 +371,7 @@ int ConstantPropagationPass::Run(HIRBuilder* builder) { case OPCODE_CNTLZ: if (i->src1.value->IsConstant()) { v->set_zero(v->type); - v->CountLeadingZeros(i->src1.value->constant); + v->CountLeadingZeros(i->src1.value); i->Remove(); } break; diff --git a/src/alloy/hir/value.cc b/src/alloy/hir/value.cc index f70d6ceb2..10fc62cad 100644 --- a/src/alloy/hir/value.cc +++ b/src/alloy/hir/value.cc @@ -560,19 +560,19 @@ void Value::ByteSwap() { } } -void Value::CountLeadingZeros(const ConstantValue& src) { - switch (type) { +void Value::CountLeadingZeros(const Value* other) { + switch (other->type) { case INT8_TYPE: - constant.i8 = __lzcnt16(src.i8) - 8; + constant.i8 = static_cast(__lzcnt16(other->constant.i8) - 8); break; case INT16_TYPE: - constant.i8 = __lzcnt16(src.i16); + constant.i8 = static_cast(__lzcnt16(other->constant.i16)); break; case INT32_TYPE: - constant.i8 = __lzcnt(src.i32); + constant.i8 = static_cast(__lzcnt(other->constant.i32)); break; case INT64_TYPE: - constant.i8 = __lzcnt64(src.i64); + constant.i8 = static_cast(__lzcnt64(other->constant.i64)); break; default: XEASSERTALWAYS(); diff --git a/src/alloy/hir/value.h b/src/alloy/hir/value.h index e3af4906f..9a1f668f5 100644 --- a/src/alloy/hir/value.h +++ b/src/alloy/hir/value.h @@ -393,7 +393,7 @@ public: void Shr(Value* other); void Sha(Value* other); void ByteSwap(); - void CountLeadingZeros(const ConstantValue& src); + void CountLeadingZeros(const Value* other); bool Compare(Opcode opcode, Value* other); };