-
Notifications
You must be signed in to change notification settings - Fork 5k
[arm64] JIT: Fold "A * B + C" to MADD/MSUB #61037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
74bd53d
eb100e1
046cd22
c7a9da9
5b1bc8f
40299d6
7bf486d
8ae926f
2591841
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13597,6 +13597,44 @@ regNumber emitter::emitInsTernary(instruction ins, emitAttr attr, GenTree* dst, | |
// src2 can only be a reg | ||
assert(!src2->isContained()); | ||
} | ||
else if ((src1->OperIs(GT_MUL) && src1->isContained()) || (src2->OperIs(GT_MUL) && src2->isContained())) | ||
{ | ||
assert(ins == INS_add); | ||
|
||
GenTree* mul; | ||
GenTree* c; | ||
if (src1->OperIs(GT_MUL)) | ||
{ | ||
mul = src1; | ||
c = src2; | ||
} | ||
else | ||
{ | ||
mul = src2; | ||
c = src1; | ||
} | ||
|
||
GenTree* a = mul->gtGetOp1(); | ||
GenTree* b = mul->gtGetOp2(); | ||
|
||
assert(varTypeIsIntegral(mul) && !mul->gtOverflow()); | ||
|
||
bool msub = false; | ||
if (a->OperIs(GT_NEG) && a->isContained()) | ||
{ | ||
a = a->gtGetOp1(); | ||
msub = true; | ||
} | ||
if (b->OperIs(GT_NEG) && b->isContained()) | ||
{ | ||
b = b->gtGetOp1(); | ||
msub = !msub; // it's either "a * -b" or "-a * -b" which is the same as "a * b" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This comment is little misleading...I can see how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
actually for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah...I misread this |
||
} | ||
|
||
emitIns_R_R_R_R(msub ? INS_msub : INS_madd, attr, dst->GetRegNum(), a->GetRegNum(), b->GetRegNum(), | ||
c->GetRegNum()); | ||
return dst->GetRegNum(); | ||
} | ||
else // not floating point | ||
{ | ||
// src2 can be immed or reg | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the
src1->gtGetOp1()
orsrc1->gtGetOp2()
would be the one that is marked contained in lower and that should be checked here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
madd
fotGT_ADD
can only be emitted when GT_MUL is contained. So "isContaind" here basically means lower approved this tree to be optimized into madd. GT_MUL can be not contained e.g. if it has gtOverflow set