Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e8f9ae6
Add lowering support for conditional nodes
a74nh Mar 22, 2022
e9c0474
Contain conditionals
a74nh Jul 8, 2022
97386b3
Fix formatting
a74nh Jul 11, 2022
1bcd61a
Use AND and CMP nodes
a74nh Jul 12, 2022
7884eca
Fix formatting
a74nh Jul 18, 2022
6d36f9d
Remove LowerNodeCC changes
a74nh Jul 18, 2022
1138fae
Remove asserts & fix variable names
a74nh Jul 19, 2022
d98f9d0
Better contain checks for conditional compares
a74nh Jul 19, 2022
8ef9994
Simpler contained conditions codegen
a74nh Jul 20, 2022
6202894
Remove Conditional Compare nodes
a74nh Jul 18, 2022
c0aba37
Minor cleanups
a74nh Jul 20, 2022
9995881
Generate AND compare chains
a74nh Jul 26, 2022
165060b
Fix unsigned compares && reduce chain check recursion
a74nh Aug 3, 2022
6117333
Add compare chain tests
a74nh Aug 3, 2022
574742f
Review fixes
a74nh Aug 3, 2022
eae824a
Use GenCondition
a74nh Aug 4, 2022
8b282f9
Change CompareChainSize to IsValidCompareChain
a74nh Aug 4, 2022
ce5882d
Move lowering functions to lowerarmarch
a74nh Aug 4, 2022
c548f9f
Formatting fixes
a74nh Aug 4, 2022
df67d67
Fix SELECT issues
a74nh Aug 5, 2022
d1854f8
Fix test output messages.
a74nh Aug 5, 2022
8310017
Better explanations for AND chains
a74nh Aug 5, 2022
e2c8f5d
Compare chains should not contain tst compares
a74nh Aug 8, 2022
25696f1
Don't allow tst compares in codegeneration of compare chains
a74nh Aug 9, 2022
a3d5d0c
Add tests for chains with tst compares
a74nh Aug 9, 2022
cac2740
Don't allow tst compares in lsrabuild of compare chains
a74nh Aug 9, 2022
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
Prev Previous commit
Next Next commit
Better explanations for AND chains
  • Loading branch information
a74nh committed Aug 5, 2022
commit 83100179043fc4ce9f57df4aeffc2e35ed3a6465
2 changes: 1 addition & 1 deletion src/coreclr/jit/lower.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Lowering final : public Phase
#ifdef TARGET_ARM64
bool IsValidCompareChain(GenTree* child, GenTree* parent);
bool ContainCheckCompareChain(GenTree* child, GenTree* parent, GenTree** earliestValid);
void ContainCheckAndChain(GenTree* tree);
void ContainCheckCompareChainForAnd(GenTree* tree);
void ContainCheckConditionalCompare(GenTreeOp* cmp);
void ContainCheckSelect(GenTreeConditional* node);
#endif
Expand Down
25 changes: 20 additions & 5 deletions src/coreclr/jit/lowerarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ GenTree* Lowering::LowerBinaryArithmetic(GenTreeOp* binOp)
#ifdef TARGET_ARM64
else
{
ContainCheckAndChain(binOp);
ContainCheckCompareChainForAnd(binOp);
}
#endif
}
Expand Down Expand Up @@ -2050,7 +2050,7 @@ void Lowering::ContainCheckCompare(GenTreeOp* cmp)

#ifdef TARGET_ARM64
//------------------------------------------------------------------------
// IsValidCompareChain : Determine if the node contains a valid compare chain.
// IsValidCompareChain : Determine if the node contains a valid chain of ANDs and CMPs.
//
// Arguments:
// child - pointer to the node being checked.
Expand All @@ -2059,6 +2059,15 @@ void Lowering::ContainCheckCompare(GenTreeOp* cmp)
// Return value:
// True if a valid chain is found.
//
// Notes:
// A compare chain is a sequence of CMP nodes connected by AND nodes.
// For example: AND (AND (CMP A B) (CMP C D)) (CMP E F)
// The chain can just be a single compare node, however it's parent
// must always be an AND or SELECT node.
// If a CMP or AND node is contained then it and all it's children are
// considered to be in a valid chain.
// Chains are built up during the lowering of each successive parent.
//
bool Lowering::IsValidCompareChain(GenTree* child, GenTree* parent)
{
assert(parent->OperIs(GT_AND) || parent->OperIs(GT_SELECT));
Expand Down Expand Up @@ -2095,6 +2104,12 @@ bool Lowering::IsValidCompareChain(GenTree* child, GenTree* parent)
// parent - parent node of the child.
// startOfChain - If found, returns the earliest valid op in the chain.
//
// Return value:
// True if a valid chain is was contained.
//
// Notes:
// Assumes the chain was checked via IsValidCompareChain.
//
bool Lowering::ContainCheckCompareChain(GenTree* child, GenTree* parent, GenTree** startOfChain)
{
assert(parent->OperIs(GT_AND) || parent->OperIs(GT_SELECT));
Expand Down Expand Up @@ -2150,12 +2165,12 @@ bool Lowering::ContainCheckCompareChain(GenTree* child, GenTree* parent, GenTree
}

//------------------------------------------------------------------------
// ContainCheckAndCompareChain : Determine if an AND is a containable chain
// ContainCheckCompareChainForAnd : Determine if an AND is a containable chain
//
// Arguments:
// node - pointer to the node
//
void Lowering::ContainCheckAndChain(GenTree* tree)
void Lowering::ContainCheckCompareChainForAnd(GenTree* tree)
{
assert(tree->OperIs(GT_AND));

Expand Down Expand Up @@ -2187,7 +2202,7 @@ void Lowering::ContainCheckAndChain(GenTree* tree)
}
}

JITDUMP("Lowered And chain:\n");
JITDUMP("Lowered `AND` chain:\n");
DISPTREE(tree);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lsrabuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3145,7 +3145,7 @@ int LinearScan::BuildOperandUses(GenTree* node, regMaskTP candidates)
if (node->OperIs(GT_MUL) || node->OperIsCompare() || node->OperIs(GT_AND))
{
// Can be contained for MultiplyAdd on arm64.
// Compare and And may be contained due to If Conversion.
// Compare and AND may be contained due to If Conversion.
return BuildBinaryUses(node->AsOp(), candidates);
}
if (node->OperIs(GT_NEG, GT_CAST, GT_LSH))
Expand Down