@@ -3233,7 +3233,7 @@ int LinearScan::BuildMul(GenTree* tree)
3233
3233
3234
3234
bool isUnsignedMultiply = tree->IsUnsigned ();
3235
3235
bool requiresOverflowCheck = tree->gtOverflowEx ();
3236
- bool useMulx = tree->OperGet () != GT_MUL && isUnsignedMultiply &&
3236
+ bool useMulx = ! tree->OperIs ( GT_MUL) && isUnsignedMultiply &&
3237
3237
compiler->compOpportunisticallyDependsOn (InstructionSet_AVX2);
3238
3238
3239
3239
// ToDo-APX : imul currently doesn't have rex2 support. So, cannot use R16-R31.
@@ -3250,15 +3250,18 @@ int LinearScan::BuildMul(GenTree* tree)
3250
3250
// Lowering has ensured that op1 is never the memory operand
3251
3251
assert (!op1->isUsedFromMemory ());
3252
3252
3253
- // prefer to have the constant in RDX (op1) this is especially useful for MUL_HI usage
3254
- if (op2->IsCnsIntOrI ())
3253
+ SingleTypeRegSet srcCandidates1 = RBM_NONE;
3254
+
3255
+ // If one of the operands is a memory address, specify RDX for the other operand
3256
+ if (op2->isUsedFromMemory ())
3255
3257
{
3256
- std::swap (op1, op2);
3258
+ // If op2 is a memory operand, we place it in RDX
3259
+ srcCandidates1 = SRBM_RDX;
3257
3260
}
3258
3261
3259
3262
// In lowering, we place any memory operand in op2 so we default to placing op1 in RDX
3260
3263
// By selecting RDX here we don't have to kill it
3261
- srcCount = BuildOperandUses (op1, SRBM_RDX );
3264
+ srcCount = BuildOperandUses (op1, srcCandidates1 );
3262
3265
srcCount += BuildOperandUses (op2, RBM_NONE);
3263
3266
}
3264
3267
else
0 commit comments