Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Remove TYP_BOOL #90981

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ bool IntegralRange::Contains(int64_t value) const
{
switch (type)
{
case TYP_BOOL:
case TYP_UBYTE:
case TYP_USHORT:
return SymbolicIntegerValue::Zero;
Expand Down Expand Up @@ -113,7 +112,6 @@ bool IntegralRange::Contains(int64_t value) const
{
case TYP_BYTE:
return SymbolicIntegerValue::ByteMax;
case TYP_BOOL:
case TYP_UBYTE:
return SymbolicIntegerValue::UByteMax;
case TYP_SHORT:
Expand Down Expand Up @@ -890,7 +888,6 @@ ssize_t Compiler::optCastConstantSmall(ssize_t iconVal, var_types smallType)
case TYP_USHORT:
return uint16_t(iconVal);

case TYP_BOOL:
case TYP_UBYTE:
return uint8_t(iconVal);

Expand Down Expand Up @@ -2708,7 +2705,6 @@ GenTree* Compiler::optVNConstantPropOnTree(BasicBlock* block, GenTree* tree)
unreached();
break;

case TYP_BOOL:
case TYP_BYTE:
case TYP_UBYTE:
case TYP_SHORT:
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6735,7 +6735,7 @@ void CodeGen::genCompareFloat(GenTree* treeNode)
if (((op1->gtGetContainedRegMask() | op2->gtGetContainedRegMask()) & targetRegMask) == 0)
{
instGen_Set_Reg_To_Zero(emitTypeSize(TYP_I_IMPL), targetReg);
targetType = TYP_BOOL; // just a tip for inst_SETCC that movzx is not needed
targetType = TYP_UBYTE; // just a tip for inst_SETCC that movzx is not needed
}
}
GetEmitter()->emitInsBinary(ins, cmpAttr, op1, op2);
Expand Down Expand Up @@ -6906,7 +6906,7 @@ void CodeGen::genCompareInt(GenTree* treeNode)
if (((op1->gtGetContainedRegMask() | op2->gtGetContainedRegMask()) & targetRegMask) == 0)
{
instGen_Set_Reg_To_Zero(emitTypeSize(TYP_I_IMPL), targetReg);
targetType = TYP_BOOL; // just a tip for inst_SETCC that movzx is not needed
targetType = TYP_UBYTE; // just a tip for inst_SETCC that movzx is not needed
}
}

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ class LclVarDsc
unsigned char lvIsSplit : 1; // Set if the argument is splited.
#endif // defined(TARGET_RISCV64)

unsigned char lvIsBoolean : 1; // set if variable is boolean
unsigned char lvSingleDef : 1; // variable has a single def. Used to identify ref type locals that can get type
// updates

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/ee_il_dll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ inline var_types JITtype2varType(CorInfoType type)
// see the definition of enum CorInfoType in file inc/corinfo.h
TYP_UNDEF, // CORINFO_TYPE_UNDEF = 0x0,
TYP_VOID, // CORINFO_TYPE_VOID = 0x1,
TYP_BOOL, // CORINFO_TYPE_BOOL = 0x2,
TYP_UBYTE, // CORINFO_TYPE_BOOL = 0x2,
TYP_USHORT, // CORINFO_TYPE_CHAR = 0x3,
TYP_BYTE, // CORINFO_TYPE_BYTE = 0x4,
TYP_UBYTE, // CORINFO_TYPE_UBYTE = 0x5,
Expand Down Expand Up @@ -235,7 +235,7 @@ inline var_types JitType2PreciseVarType(CorInfoType type)
// see the definition of enum CorInfoType in file inc/corinfo.h
TYP_UNDEF, // CORINFO_TYPE_UNDEF = 0x0,
TYP_VOID, // CORINFO_TYPE_VOID = 0x1,
TYP_BOOL, // CORINFO_TYPE_BOOL = 0x2,
TYP_UBYTE, // CORINFO_TYPE_BOOL = 0x2,
TYP_USHORT, // CORINFO_TYPE_CHAR = 0x3,
TYP_BYTE, // CORINFO_TYPE_BYTE = 0x4,
TYP_UBYTE, // CORINFO_TYPE_UBYTE = 0x5,
Expand Down
9 changes: 3 additions & 6 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7696,7 +7696,6 @@ GenTree* Compiler::gtNewGenericCon(var_types type, uint8_t* cnsVal)
READ_VALUE(int8_t);
return gtNewIconNode(val);
}
case TYP_BOOL:
case TYP_UBYTE:
{
READ_VALUE(uint8_t);
Expand Down Expand Up @@ -7790,7 +7789,6 @@ GenTree* Compiler::gtNewConWithPattern(var_types type, uint8_t pattern)
{
switch (type)
{
case TYP_BOOL:
case TYP_UBYTE:
return gtNewIconNode(pattern);
case TYP_BYTE:
Expand Down Expand Up @@ -14279,7 +14277,7 @@ GenTree* Compiler::gtFoldBoxNullable(GenTree* tree)

static_assert_no_msg(OFFSETOF__CORINFO_NullableOfT__hasValue == 0);
GenTree* srcAddr = call->gtArgs.GetArgByIndex(1)->GetNode();
GenTree* hasValueNode = gtNewIndir(TYP_BOOL, srcAddr);
GenTree* hasValueNode = gtNewIndir(TYP_UBYTE, srcAddr);

if (op == op1)
{
Expand Down Expand Up @@ -14849,7 +14847,6 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree)
i1 = INT32(UINT16(i1));
goto CNS_INT;

case TYP_BOOL:
case TYP_UBYTE:
i1 = INT32(UINT8(i1));
goto CNS_INT;
Expand Down Expand Up @@ -21333,7 +21330,7 @@ GenTree* Compiler::gtNewSimdCmpOpAllNode(
genTreeOps op, var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize)
{
assert(IsBaselineSimdIsaSupportedDebugOnly());
assert(type == TYP_BOOL);
assert(type == TYP_UBYTE);

var_types simdType = getSIMDTypeForSize(simdSize);
assert(varTypeIsSIMD(simdType));
Expand Down Expand Up @@ -21472,7 +21469,7 @@ GenTree* Compiler::gtNewSimdCmpOpAnyNode(
genTreeOps op, var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize)
{
assert(IsBaselineSimdIsaSupportedDebugOnly());
assert(type == TYP_BOOL);
assert(type == TYP_UBYTE);

var_types simdType = getSIMDTypeForSize(simdSize);
assert(varTypeIsSIMD(simdType));
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,9 @@ bool Compiler::impCheckImplicitArgumentCoercion(var_types sigType, var_types nod
return true;
}

if (TypeIs(sigType, TYP_BOOL, TYP_UBYTE, TYP_BYTE, TYP_USHORT, TYP_SHORT, TYP_UINT, TYP_INT))
if (TypeIs(sigType, TYP_UBYTE, TYP_BYTE, TYP_USHORT, TYP_SHORT, TYP_UINT, TYP_INT))
{
if (TypeIs(nodeType, TYP_BOOL, TYP_UBYTE, TYP_BYTE, TYP_USHORT, TYP_SHORT, TYP_UINT, TYP_INT, TYP_I_IMPL))
if (TypeIs(nodeType, TYP_UBYTE, TYP_BYTE, TYP_USHORT, TYP_SHORT, TYP_UINT, TYP_INT, TYP_I_IMPL))
{
return true;
}
Expand Down Expand Up @@ -2990,7 +2990,7 @@ int Compiler::impBoxPatternMatch(CORINFO_RESOLVED_TOKEN* pResolvedToken,
objToBox = impGetNodeAddr(objToBox, CHECK_SPILL_ALL, &indirFlags);

static_assert_no_msg(OFFSETOF__CORINFO_NullableOfT__hasValue == 0);
impPushOnStack(gtNewIndir(TYP_BOOL, objToBox), typeInfo(TYP_INT));
impPushOnStack(gtNewIndir(TYP_UBYTE, objToBox), typeInfo(TYP_INT));

JITDUMP("\n Importing BOX; ISINST; BR_TRUE/FALSE as nullableVT.hasValue\n");
return 1 + sizeof(mdToken);
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/importervectorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ GenTree* Compiler::impExpandHalfConstEqualsSIMD(
// Optimization: use a single load when byteLen equals simdSize.
// For code simplicity we always create nodes for two vectors case.
const bool useSingleVector = simdSize == byteLen;
return gtNewSimdCmpOpAllNode(GT_EQ, TYP_BOOL, useSingleVector ? xor1 : orr, gtNewZeroConNode(simdType), baseType,
return gtNewSimdCmpOpAllNode(GT_EQ, TYP_UBYTE, useSingleVector ? xor1 : orr, gtNewZeroConNode(simdType), baseType,
simdSize);

// Codegen example for byteLen=40 and OrdinalIgnoreCase mode with AVX:
Expand Down Expand Up @@ -486,7 +486,7 @@ GenTree* Compiler::impExpandHalfConstEquals(GenTreeLclVarCommon* data,
JITDUMP("unable to compose indirCmp\n");
return nullptr;
}
assert(indirCmp->TypeIs(TYP_INT, TYP_BOOL));
assert(indirCmp->TypeIs(TYP_INT, TYP_UBYTE));

GenTreeColon* lenCheckColon = gtNewColonNode(TYP_INT, indirCmp, gtNewFalse());

Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/jit/lclmorph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,13 +1144,6 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>
return IndirTransform::LclVar;
}

// Bool and ubyte are the same type.
if ((indir->TypeIs(TYP_BOOL) && (varDsc->TypeGet() == TYP_UBYTE)) ||
(indir->TypeIs(TYP_UBYTE) && (varDsc->TypeGet() == TYP_BOOL)))
{
return IndirTransform::LclVar;
}

// For small stores we can ignore the signed/unsigned diff.
if (isDef && (varTypeToSigned(indir) == varTypeToSigned(varDsc)))
{
Expand Down
34 changes: 0 additions & 34 deletions src/coreclr/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1501,11 +1501,6 @@ void Compiler::lvaInitVarDsc(LclVarDsc* varDsc,
varDsc->lvType = type;
}

if (type == TYP_BOOL)
{
varDsc->lvIsBoolean = true;
}

#ifdef DEBUG
varDsc->SetStackOffset(BAD_STK_OFFS);
#endif
Expand Down Expand Up @@ -4078,7 +4073,6 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,
{
if (varDsc->IsAddressExposed())
{
varDsc->lvIsBoolean = false;
varDsc->lvAllDefsAreNoGc = false;
}

Expand All @@ -4101,34 +4095,6 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,
varDsc->lvAllDefsAreNoGc = false;
}

if (value->gtType != TYP_BOOL)
{
// Is the value clearly a boolean one?
switch (value->gtOper)
{
case GT_CNS_INT:
if (value->AsIntCon()->gtIconVal == 0)
{
break;
}
if (value->AsIntCon()->gtIconVal == 1)
{
break;
}

// Not 0 or 1, fall through ....
FALLTHROUGH;
default:
if (value->OperIsCompare())
{
break;
}

varDsc->lvIsBoolean = false;
break;
}
}

if (!varDsc->lvDisqualifySingleDefRegCandidate) // If this var is already disqualified, we can skip this
{
bool bbInALoop = (block->bbFlags & BBF_BACKWARD_JUMP) != 0;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,7 @@ GenTree* Lowering::LowerCallMemcmp(GenTreeCall* call)
if (GenTree::OperIsCmpCompare(oper))
{
assert(type == TYP_INT);
return comp->gtNewSimdCmpOpAllNode(oper, TYP_BOOL, op1, op2, CORINFO_TYPE_NATIVEUINT,
return comp->gtNewSimdCmpOpAllNode(oper, TYP_UBYTE, op1, op2, CORINFO_TYPE_NATIVEUINT,
genTypeSize(op1));
}
return comp->gtNewSimdBinOpNode(oper, op1->TypeGet(), op1, op2, CORINFO_TYPE_NATIVEUINT,
Expand Down Expand Up @@ -3441,7 +3441,7 @@ GenTree* Lowering::OptimizeConstCompare(GenTree* cmp)
var_types castToType = cast->CastToType();
GenTree* castOp = cast->gtGetOp1();

if (((castToType == TYP_BOOL) || (castToType == TYP_UBYTE)) && FitsIn<UINT8>(op2Value))
if ((castToType == TYP_UBYTE) && FitsIn<UINT8>(op2Value))
{
//
// Since we're going to remove the cast we need to be able to narrow the cast operand
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lowerarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ GenTree* Lowering::LowerHWIntrinsicCmpOp(GenTreeHWIntrinsic* node, genTreeOps cm
assert(varTypeIsSIMD(simdType));
assert(varTypeIsArithmetic(simdBaseType));
assert(simdSize != 0);
assert(node->gtType == TYP_BOOL);
assert(node->gtType == TYP_UBYTE);
assert((cmpOp == GT_EQ) || (cmpOp == GT_NE));

// We have the following (with the appropriate simd size and where the intrinsic could be op_Inequality):
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,7 @@ GenTree* Lowering::LowerHWIntrinsicCmpOp(GenTreeHWIntrinsic* node, genTreeOps cm
assert(varTypeIsSIMD(simdType));
assert(varTypeIsArithmetic(simdBaseType));
assert(simdSize != 0);
assert(node->gtType == TYP_BOOL);
assert(node->gtType == TYP_UBYTE);
assert((cmpOp == GT_EQ) || (cmpOp == GT_NE));

// We have the following (with the appropriate simd size and where the intrinsic could be op_Inequality):
Expand Down
15 changes: 1 addition & 14 deletions src/coreclr/jit/optimizebools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,7 @@ GenTree* OptBoolsDsc::optIsBoolComp(OptTestInfo* pOptTest)
ssize_t ival2 = opr2->AsIntCon()->gtIconVal;

// Is the value a boolean?
// We can either have a boolean expression (marked GTF_BOOLEAN) or
// a local variable that is marked as being boolean (lvIsBoolean)
// We can either have a boolean expression (marked GTF_BOOLEAN) or a constant 0/1.

if (opr1->gtFlags & GTF_BOOLEAN)
{
Expand All @@ -1293,18 +1292,6 @@ GenTree* OptBoolsDsc::optIsBoolComp(OptTestInfo* pOptTest)
{
pOptTest->isBool = true;
}
else if (opr1->gtOper == GT_LCL_VAR)
{
// is it a boolean local variable?

unsigned lclNum = opr1->AsLclVarCommon()->GetLclNum();
noway_assert(lclNum < m_comp->lvaCount);

if (m_comp->lvaTable[lclNum].lvIsBoolean)
{
pOptTest->isBool = true;
}
}

// Was our comparison against the constant 1 (i.e. true)
if (ival2 == 1)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5734,7 +5734,6 @@ bool Compiler::optNarrowTree(GenTree* tree, var_types srct, var_types dstt, Valu
case TYP_BYTE:
lmask = 0x0000007F;
break;
case TYP_BOOL:
case TYP_UBYTE:
lmask = 0x000000FF;
break;
Expand Down Expand Up @@ -5782,7 +5781,6 @@ bool Compiler::optNarrowTree(GenTree* tree, var_types srct, var_types dstt, Valu
case TYP_BYTE:
imask = 0x0000007F;
break;
case TYP_BOOL:
case TYP_UBYTE:
imask = 0x000000FF;
break;
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/rangecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,6 @@ Range RangeCheck::GetRangeFromType(var_types type)
{
switch (type)
{
case TYP_BOOL:
case TYP_UBYTE:
return Range(Limit(Limit::keConstant, 0), Limit(Limit::keConstant, BYTE_MAX));
case TYP_BYTE:
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/typelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ tf )
DEF_TP(UNDEF ,"<UNDEF>" , TYP_UNDEF, 0, 0, 0, 0, 0, VTR_INT, availableIntRegs, RBM_INT_CALLEE_SAVED, RBM_INT_CALLEE_TRASH, VTF_ANY)
DEF_TP(VOID ,"void" , TYP_VOID, 0, 0, 0, 0, 0, VTR_INT, availableIntRegs, RBM_INT_CALLEE_SAVED, RBM_INT_CALLEE_TRASH, VTF_ANY)

DEF_TP(BOOL ,"bool" , TYP_INT, 1, 1, 4, 1, 1, VTR_INT, availableIntRegs, RBM_INT_CALLEE_SAVED, RBM_INT_CALLEE_TRASH, VTF_INT|VTF_UNS)
DEF_TP(BYTE ,"byte" , TYP_INT, 1, 1, 4, 1, 1, VTR_INT, availableIntRegs, RBM_INT_CALLEE_SAVED, RBM_INT_CALLEE_TRASH, VTF_INT)
DEF_TP(UBYTE ,"ubyte" , TYP_INT, 1, 1, 4, 1, 1, VTR_INT, availableIntRegs, RBM_INT_CALLEE_SAVED, RBM_INT_CALLEE_TRASH, VTF_INT|VTF_UNS)

Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/jit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3855,7 +3855,6 @@ bool CastFromIntOverflows(int32_t fromValue, var_types toType, bool fromUnsigned
{
switch (toType)
{
case TYP_BOOL:
case TYP_BYTE:
case TYP_UBYTE:
case TYP_SHORT:
Expand All @@ -3879,7 +3878,6 @@ bool CastFromLongOverflows(int64_t fromValue, var_types toType, bool fromUnsigne
{
switch (toType)
{
case TYP_BOOL:
case TYP_BYTE:
case TYP_UBYTE:
case TYP_SHORT:
Expand Down Expand Up @@ -3994,7 +3992,6 @@ bool CastFromFloatOverflows(float fromValue, var_types toType)
{
case TYP_BYTE:
return !(-129.0f < fromValue && fromValue < 128.0f);
case TYP_BOOL:
case TYP_UBYTE:
return !(-1.0f < fromValue && fromValue < 256.0f);
case TYP_SHORT:
Expand Down Expand Up @@ -4023,7 +4020,6 @@ bool CastFromDoubleOverflows(double fromValue, var_types toType)
{
case TYP_BYTE:
return !(-129.0 < fromValue && fromValue < 128.0);
case TYP_BOOL:
case TYP_UBYTE:
return !(-1.0 < fromValue && fromValue < 256.0);
case TYP_SHORT:
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,6 @@ bool FitsIn(var_types type, T value)
{
case TYP_BYTE:
return FitsIn<int8_t>(value);
case TYP_BOOL:
case TYP_UBYTE:
return FitsIn<uint8_t>(value);
case TYP_SHORT:
Expand Down
Loading
Loading