diff --git a/src/coreclr/jit/codegenarm64.cpp b/src/coreclr/jit/codegenarm64.cpp index 7a5e9122fcc38..7831b66ecaae6 100644 --- a/src/coreclr/jit/codegenarm64.cpp +++ b/src/coreclr/jit/codegenarm64.cpp @@ -3571,7 +3571,6 @@ void CodeGen::genCodeForCompare(GenTreeOp* tree) var_types op2Type = genActualType(op2->TypeGet()); assert(!op1->isUsedFromMemory()); - assert(!op2->isUsedFromMemory()); genConsumeOperands(tree); @@ -3585,7 +3584,7 @@ void CodeGen::genCodeForCompare(GenTreeOp* tree) assert(!op1->isContained()); assert(op1Type == op2Type); - if (op2->IsIntegralConst(0)) + if (op2->IsFPZero()) { assert(op2->isContained()); emit->emitIns_R_F(INS_fcmp, cmpSize, op1->GetRegNum(), 0.0); diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index bc6459eb0da0a..b524efa4790b8 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -48,13 +48,22 @@ bool Lowering::IsCallTargetInRange(void* addr) // True if the immediate can be folded into an instruction, // for example small enough and non-relocatable. // -// TODO-CQ: we can contain a floating point 0.0 constant in a compare instruction -// (vcmp on arm, fcmp on arm64). -// bool Lowering::IsContainableImmed(GenTree* parentNode, GenTree* childNode) const { if (!varTypeIsFloating(parentNode->TypeGet())) { +#ifdef TARGET_ARM64 + if (parentNode->OperIsRelop() && childNode->IsFPZero()) + { + // Contain 0.0 constant in fcmp on arm64 + // TODO: Enable for arm too (vcmp) + + // We currently don't emit these for floating points + assert(!parentNode->OperIs(GT_TEST_EQ, GT_TEST_NE)); + return true; + } +#endif + // Make sure we have an actual immediate if (!childNode->IsCnsIntOrI()) return false;