Skip to content

Commit c397327

Browse files
authored
[arm64] JIT: Make 0.0 containable for fcmp (#61617)
1 parent c566e25 commit c397327

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/coreclr/jit/codegenarm64.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,7 +3571,6 @@ void CodeGen::genCodeForCompare(GenTreeOp* tree)
35713571
var_types op2Type = genActualType(op2->TypeGet());
35723572

35733573
assert(!op1->isUsedFromMemory());
3574-
assert(!op2->isUsedFromMemory());
35753574

35763575
genConsumeOperands(tree);
35773576

@@ -3585,7 +3584,7 @@ void CodeGen::genCodeForCompare(GenTreeOp* tree)
35853584
assert(!op1->isContained());
35863585
assert(op1Type == op2Type);
35873586

3588-
if (op2->IsIntegralConst(0))
3587+
if (op2->IsFPZero())
35893588
{
35903589
assert(op2->isContained());
35913590
emit->emitIns_R_F(INS_fcmp, cmpSize, op1->GetRegNum(), 0.0);

src/coreclr/jit/lowerarmarch.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,22 @@ bool Lowering::IsCallTargetInRange(void* addr)
4848
// True if the immediate can be folded into an instruction,
4949
// for example small enough and non-relocatable.
5050
//
51-
// TODO-CQ: we can contain a floating point 0.0 constant in a compare instruction
52-
// (vcmp on arm, fcmp on arm64).
53-
//
5451
bool Lowering::IsContainableImmed(GenTree* parentNode, GenTree* childNode) const
5552
{
5653
if (!varTypeIsFloating(parentNode->TypeGet()))
5754
{
55+
#ifdef TARGET_ARM64
56+
if (parentNode->OperIsRelop() && childNode->IsFPZero())
57+
{
58+
// Contain 0.0 constant in fcmp on arm64
59+
// TODO: Enable for arm too (vcmp)
60+
61+
// We currently don't emit these for floating points
62+
assert(!parentNode->OperIs(GT_TEST_EQ, GT_TEST_NE));
63+
return true;
64+
}
65+
#endif
66+
5867
// Make sure we have an actual immediate
5968
if (!childNode->IsCnsIntOrI())
6069
return false;

0 commit comments

Comments
 (0)