Skip to content

Commit

Permalink
JIT: Remove GTF_BOOLEAN (#104779)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbotsch authored Jul 13, 2024
1 parent ee5770d commit 7f88171
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 51 deletions.
4 changes: 0 additions & 4 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10411,10 +10411,6 @@ JITDBGAPI void __cdecl cTreeFlags(Compiler* comp, GenTree* tree)
{
chars += printf("[DONT_CSE]");
}
if (tree->gtFlags & GTF_BOOLEAN)
{
chars += printf("[BOOLEAN]");
}
if (tree->gtFlags & GTF_UNSIGNED)
{
chars += printf("[SMALL_UNSIGNED]");
Expand Down
27 changes: 1 addition & 26 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10605,7 +10605,7 @@ bool GenTree::HandleKindDataIsInvariant(GenTreeFlags flags)
(flags & GTF_MAKE_CSE) ? 'H'
: '-'); // H is for Hoist this expr
printf("%c", (flags & GTF_REVERSE_OPS) ? 'R' : '-');
printf("%c", (flags & GTF_UNSIGNED) ? 'U' : (flags & GTF_BOOLEAN) ? 'B' : '-');
printf("%c", (flags & GTF_UNSIGNED) ? 'U' : '-');

// Both GTF_SPILL and GTF_SPILLED: '#'
// Only GTF_SPILLED: 'z'
Expand Down Expand Up @@ -14284,21 +14284,6 @@ GenTree* Compiler::gtFoldExprSpecial(GenTree* tree)
op = NewZeroExtendNode(tree->TypeGet(), op, TYP_UINT);
goto DONE_FOLD;
}
else
{
/* The GTF_BOOLEAN flag is set for nodes that are part
* of a boolean expression, thus all their children
* are known to evaluate to only 0 or 1 */

if (tree->gtFlags & GTF_BOOLEAN)
{

/* The constant value must be 1
* AND with 1 stays the same */
assert(val == 1);
goto DONE_FOLD;
}
}
break;
}

Expand All @@ -14308,16 +14293,6 @@ GenTree* Compiler::gtFoldExprSpecial(GenTree* tree)
{
goto DONE_FOLD;
}
else if (tree->gtFlags & GTF_BOOLEAN)
{
/* The constant value must be 1 - OR with 1 is 1 */

assert(val == 1);

// OR with one - return the 'one' node
op = gtWrapWithSideEffects(cons, op, GTF_ALL_EFFECT);
goto DONE_FOLD;
}
break;
}

Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,6 @@ enum GenTreeFlags : unsigned int

GTF_NODE_MASK = GTF_COLON_COND,

GTF_BOOLEAN = 0x00004000, // value is known to be 0/1

GTF_UNSIGNED = 0x00008000, // With GT_CAST: the source operand is an unsigned type
// With operators: the specified node is an unsigned operator
GTF_SPILL = 0x00020000, // Needs to be spilled here
Expand All @@ -413,7 +411,7 @@ enum GenTreeFlags : unsigned int
// The only requirement of this flag is that it not overlap any of the
// side-effect flags. The actual bit used is otherwise arbitrary.

GTF_IS_IN_CSE = GTF_BOOLEAN,
GTF_IS_IN_CSE = 0x00004000,

GTF_COMMON_MASK = 0x0003FFFF, // mask of all the flags above

Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3330,14 +3330,6 @@ void Compiler::fgMoveOpsLeft(GenTree* tree)
return;
}

if ((tree->gtFlags | op2->gtFlags) & GTF_BOOLEAN)
{
// We could deal with this, but we were always broken and just hit the assert
// below regarding flags, which means it's not frequent, so will just bail out.
// See #195514
return;
}

noway_assert(!tree->gtOverflowEx() && !op2->gtOverflowEx());

GenTree* ad1 = op2->AsOp()->gtOp1;
Expand Down
11 changes: 1 addition & 10 deletions src/coreclr/jit/optimizebools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1251,11 +1251,6 @@ void OptBoolsDsc::optOptimizeBoolsUpdateTrees()
assert(m_cmpOp != GT_NONE && m_c1 != nullptr && m_c2 != nullptr);

GenTree* cmpOp1 = m_foldOp == GT_NONE ? m_c1 : m_comp->gtNewOperNode(m_foldOp, m_foldType, m_c1, m_c2);
if (m_testInfo1.isBool && m_testInfo2.isBool)
{
// When we 'OR'/'AND' two booleans, the result is boolean as well
cmpOp1->gtFlags |= GTF_BOOLEAN;
}

GenTree* t1Comp = m_testInfo1.compTree;
t1Comp->SetOper(m_cmpOp);
Expand Down Expand Up @@ -1719,11 +1714,7 @@ GenTree* OptBoolsDsc::optIsBoolComp(OptTestInfo* pOptTest)
// Is the value a boolean?
// We can either have a boolean expression (marked GTF_BOOLEAN) or a constant 0/1.

if (opr1->gtFlags & GTF_BOOLEAN)
{
pOptTest->isBool = true;
}
else if ((opr1->gtOper == GT_CNS_INT) && (opr1->IsIntegralConst(0) || opr1->IsIntegralConst(1)))
if ((opr1->gtOper == GT_CNS_INT) && (opr1->IsIntegralConst(0) || opr1->IsIntegralConst(1)))
{
pOptTest->isBool = true;
}
Expand Down

0 comments on commit 7f88171

Please sign in to comment.