Skip to content

Commit

Permalink
Revert "Fold "X relop 0" in assertprop" (#110129)
Browse files Browse the repository at this point in the history
* Revert "Fold "X relop 0" in assertprop (#110076)"

This reverts commit b5bdce2.

* Dummy edit
  • Loading branch information
jkotas authored Nov 25, 2024
1 parent 834de07 commit da9381e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 39 deletions.
39 changes: 1 addition & 38 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4295,44 +4295,6 @@ GenTree* Compiler::optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions, Gen
GenTree* op1 = tree->AsOp()->gtOp1;
GenTree* op2 = tree->AsOp()->gtOp2;

// Can we fold "X relop 0" based on assertions?
if (op2->IsIntegralConst(0) && tree->OperIsCmpCompare())
{
bool isNonZero, isNeverNegative;
optAssertionProp_RangeProperties(assertions, op1, &isNonZero, &isNeverNegative);

if (tree->OperIs(GT_GE, GT_LT) && isNeverNegative)
{
// Assertions: X >= 0
//
// X >= 0 --> true
// X < 0 --> false
newTree = tree->OperIs(GT_GE) ? gtNewTrue() : gtNewFalse();
}
else if (tree->OperIs(GT_GT, GT_LE) && isNeverNegative && isNonZero)
{
// Assertions: X > 0
//
// X > 0 --> true
// X <= 0 --> false
newTree = tree->OperIs(GT_GT) ? gtNewTrue() : gtNewFalse();
}
else if (tree->OperIs(GT_EQ, GT_NE) && isNonZero)
{
// Assertions: X != 0
//
// X != 0 --> true
// X == 0 --> false
newTree = tree->OperIs(GT_NE) ? gtNewTrue() : gtNewFalse();
}

if (newTree != tree)
{
newTree = gtWrapWithSideEffects(newTree, tree, GTF_ALL_EFFECT);
return optAssertionProp_Update(newTree, tree, stmt);
}
}

// Look for assertions of the form (tree EQ/NE 0)
AssertionIndex index = optGlobalAssertionIsEqualOrNotEqualZero(assertions, tree);

Expand All @@ -4353,6 +4315,7 @@ GenTree* Compiler::optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions, Gen

newTree = curAssertion->assertionKind == OAK_EQUAL ? gtNewIconNode(0) : gtNewIconNode(1);
newTree = gtWrapWithSideEffects(newTree, tree, GTF_ALL_EFFECT);
newTree = fgMorphTree(newTree);
DISPTREE(newTree);
return optAssertionProp_Update(newTree, tree, stmt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<IlcExportUnmanagedEntrypoints>true</IlcExportUnmanagedEntrypoints>
</PropertyGroup>
<!-- Expose unmanaged entry points from NativeExports -->
<!-- Expose unmanaged entry points from NativeExports -->
<ItemGroup Condition="'$(ReferencesNativeExports)' == 'true'">
<UnmanagedEntryPointsAssembly Include="Microsoft.Interop.Tests.NativeExports" />
<DirectPInvoke Include="Microsoft.Interop.Tests.NativeExportsNE" />
Expand Down

0 comments on commit da9381e

Please sign in to comment.