Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
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
13 changes: 2 additions & 11 deletions src/jit/hwintrinsiccodegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2316,24 +2316,15 @@ void CodeGen::genFMAIntrinsic(GenTreeHWIntrinsic* node)
op2Reg = op3->gtRegNum;
op3 = op2;
}
else if (op1->isContained() || op1->isUsedFromSpillTemp())
else
{
// 231 form: op3 = (op2 * op3) + [op1]
// 231 form: o1 = (op2 * op3) + [op1]

ins = (instruction)(ins + 1);
op1Reg = op3->gtRegNum;
op2Reg = op2->gtRegNum;
op3 = op1;
}
else
{
// 213 form: op1 = (op2 * op1) + op3

op1Reg = op1->gtRegNum;
op2Reg = op2->gtRegNum;

isCommutative = !copiesUpperBits;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure we need to keep the isCommutative handling for the cases where the multiplicand and multiplier can be swapped.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that. Thanks.

}

if (isCommutative && (op1Reg != targetReg) && (op2Reg == targetReg))
{
Expand Down
26 changes: 2 additions & 24 deletions src/jit/lsraxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2606,38 +2606,16 @@ int LinearScan::BuildHWIntrinsic(GenTreeHWIntrinsic* intrinsicTree)
srcCount += BuildOperandUses(op2);
srcCount += BuildDelayFreeUses(op3);
}
else if (op1->isContained())
else
{
// 231 form: op3 = (op2 * op3) + [op1]
// 231 form: op1 = (op2 * op3) + [op1]

tgtPrefUse = BuildUse(op3);

srcCount += BuildOperandUses(op1);
srcCount += BuildDelayFreeUses(op2);
srcCount += 1;
}
else
{
// 213 form: op1 = (op2 * op1) + op3

if (copiesUpperBits)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment, pretty sure we need to preserve this logic since op1 impacts determinism.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clarity as well, I think it makes sense to continue to keep the reg-only case separate, even if it's using the same form as the case above.

{
tgtPrefUse = BuildUse(op1);

srcCount += 1;
srcCount += BuildDelayFreeUses(op2);
}
else
{
// op1 and op2 are commutative, so don't
// set either to be tgtPref or delayFree

srcCount += BuildOperandUses(op1);
srcCount += BuildOperandUses(op2);
}

srcCount += BuildDelayFreeUses(op3);
}

buildUses = false;
break;
Expand Down