Skip to content
Merged
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
18 changes: 9 additions & 9 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2655,19 +2655,19 @@ GenTree* Compiler::optVNBasedFoldExpr_Call_Memcmp(GenTreeCall* call)
CallArg* arg2 = call->gtArgs.GetUserArgByIndex(1);
CallArg* lenArg = call->gtArgs.GetUserArgByIndex(2);

// See if arguments are the same - in that case we can optimize to constant true
ValueNum arg1VN = optConservativeNormalVN(arg1->GetNode());
ValueNum arg2VN = optConservativeNormalVN(arg2->GetNode());
if ((arg1VN != ValueNumStore::NoVN) && (arg1VN == arg2VN))
{
JITDUMP("...both arguments have the same VN -> optimize to constant true.\n");
return gtWrapWithSideEffects(gtNewIconNode(1), call, GTF_ALL_EFFECT, true);
Comment thread
EgorBo marked this conversation as resolved.
}

ValueNum lenVN = optConservativeNormalVN(lenArg->GetNode());
size_t len;
if (!vnStore->IsVNIntegralConstant(lenVN, &len))
{
// See if arguments are the same - in that case we can optimize to constant true
ValueNum arg1VN = optConservativeNormalVN(arg1->GetNode());
ValueNum arg2VN = optConservativeNormalVN(arg2->GetNode());
if ((arg1VN != ValueNumStore::NoVN) && (arg1VN == arg2VN))
{
JITDUMP("...both arguments have the same VN -> optimize to constant true.\n");
return gtWrapWithSideEffects(gtNewIconNode(1), call, GTF_ALL_EFFECT, true);
}

JITDUMP("...length is not a constant - bail out.\n");
return nullptr;
}
Expand Down
Loading