Fix cntlz.
This commit is contained in:
parent
2856d38024
commit
b0034f3b4d
|
@ -371,7 +371,7 @@ int ConstantPropagationPass::Run(HIRBuilder* builder) {
|
||||||
case OPCODE_CNTLZ:
|
case OPCODE_CNTLZ:
|
||||||
if (i->src1.value->IsConstant()) {
|
if (i->src1.value->IsConstant()) {
|
||||||
v->set_zero(v->type);
|
v->set_zero(v->type);
|
||||||
v->CountLeadingZeros(i->src1.value->constant);
|
v->CountLeadingZeros(i->src1.value);
|
||||||
i->Remove();
|
i->Remove();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -560,19 +560,19 @@ void Value::ByteSwap() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Value::CountLeadingZeros(const ConstantValue& src) {
|
void Value::CountLeadingZeros(const Value* other) {
|
||||||
switch (type) {
|
switch (other->type) {
|
||||||
case INT8_TYPE:
|
case INT8_TYPE:
|
||||||
constant.i8 = __lzcnt16(src.i8) - 8;
|
constant.i8 = static_cast<uint8_t>(__lzcnt16(other->constant.i8) - 8);
|
||||||
break;
|
break;
|
||||||
case INT16_TYPE:
|
case INT16_TYPE:
|
||||||
constant.i8 = __lzcnt16(src.i16);
|
constant.i8 = static_cast<uint8_t>(__lzcnt16(other->constant.i16));
|
||||||
break;
|
break;
|
||||||
case INT32_TYPE:
|
case INT32_TYPE:
|
||||||
constant.i8 = __lzcnt(src.i32);
|
constant.i8 = static_cast<uint8_t>(__lzcnt(other->constant.i32));
|
||||||
break;
|
break;
|
||||||
case INT64_TYPE:
|
case INT64_TYPE:
|
||||||
constant.i8 = __lzcnt64(src.i64);
|
constant.i8 = static_cast<uint8_t>(__lzcnt64(other->constant.i64));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
XEASSERTALWAYS();
|
XEASSERTALWAYS();
|
||||||
|
|
|
@ -393,7 +393,7 @@ public:
|
||||||
void Shr(Value* other);
|
void Shr(Value* other);
|
||||||
void Sha(Value* other);
|
void Sha(Value* other);
|
||||||
void ByteSwap();
|
void ByteSwap();
|
||||||
void CountLeadingZeros(const ConstantValue& src);
|
void CountLeadingZeros(const Value* other);
|
||||||
bool Compare(Opcode opcode, Value* other);
|
bool Compare(Opcode opcode, Value* other);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue