RESOLVED FIXED 227171
Add a new pattern to instruction selector to use EXTR supported by ARM64
https://bugs.webkit.org/show_bug.cgi?id=227171
Summary Add a new pattern to instruction selector to use EXTR supported by ARM64
Yijia Huang
Reported 2021-06-18 10:50:46 PDT
...
Attachments
Patch (20.59 KB, patch)
2021-06-29 23:14 PDT, Yijia Huang
no flags
Patch (24.42 KB, patch)
2021-06-30 08:56 PDT, Yijia Huang
no flags
Patch (24.48 KB, patch)
2021-06-30 11:26 PDT, Yijia Huang
no flags
Patch (24.32 KB, patch)
2021-06-30 13:22 PDT, Yijia Huang
no flags
Yijia Huang
Comment 1 2021-06-22 13:10:01 PDT
This bug will be fixed in the ubfiz patch(bug 227204).
Yijia Huang
Comment 2 2021-06-25 11:02:00 PDT
This is fixed in bug 227204.
Yijia Huang
Comment 3 2021-06-25 12:28:41 PDT
Use this bug report for other purpose: Add ARM64 BFC into AIR opcode
Yijia Huang
Comment 4 2021-06-27 14:22:33 PDT
ARM64 BFC instruction is already added in bug 227202. Use this bug report for another purpose: Add ARM64 BFXIL
Yijia Huang
Comment 5 2021-06-29 23:14:06 PDT
Radar WebKit Bug Importer
Comment 6 2021-06-29 23:14:17 PDT
Yijia Huang
Comment 7 2021-06-30 08:56:09 PDT
Filip Pizlo
Comment 8 2021-06-30 10:14:51 PDT
Comment on attachment 432600 [details] Patch Nice!
Yijia Huang
Comment 9 2021-06-30 10:19:11 PDT
(In reply to Filip Pizlo from comment #8) > Comment on attachment 432600 [details] > Patch > > Nice! Thanks for the review.
Robin Morisset
Comment 10 2021-06-30 10:19:23 PDT
Comment on attachment 432600 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=432600&action=review I like it overall, but I am concerned that you may have broken the instruction selection for sbfiz. > Source/JavaScriptCore/ChangeLog:13 > + ### Part A zero extend bitfield ### I like that, as BitAnd(value, mask) is a lot more canonical throughout the compiler. But I just checked, and your pattern for sbfiz looks for the ZShr(Shl(value, amount), amount) pattern. Have you tried running testInsertSignedBitfieldInZero64 on ARM64 ? I would expect it to fail until you replace the pattern for sbfiz in B3LowerToAir. > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:1482 > + uint64_t mask = width == datasize ? -1ULL : (1ULL << width) - 1ULL; nitpick: instead of `-1ULL` on the true side, I would put std::numeric_limits<uint64_t>::max(). It is almost certainly equivalent, but marking a negative number with U(unsigned)LL seems weird to me.
Saam Barati
Comment 11 2021-06-30 10:20:48 PDT
Comment on attachment 432600 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=432600&action=review > Source/JavaScriptCore/ChangeLog:50 > + Int @7 = ZShr(@1, @5)) @5 -> @6 > Source/JavaScriptCore/ChangeLog:51 > + Int @8 = BitOr(@7, @6) @6 -> @5 > Source/JavaScriptCore/b3/B3LowerToAir.cpp:2860 > + commitInternal(left->child(0)); > + commitInternal(left); > + commitInternal(right); Why is this valid to do? We never check canBeInternal. Since we're using "is locked" checks, isn't that enough to just grab the temp, but not commit internal? > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:1482 > + uint64_t mask = width == datasize ? -1ULL : (1ULL << width) - 1ULL; can we use numeric_limits<uint64_t>::max instead of "-1ULL" also, if "width == datasize", can't we just replace ourselves with "value"?
Yijia Huang
Comment 12 2021-06-30 10:51:09 PDT
(In reply to Robin Morisset from comment #10) > Comment on attachment 432600 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=432600&action=review > > I like it overall, but I am concerned that you may have broken the > instruction selection for sbfiz. > > > Source/JavaScriptCore/ChangeLog:13 > > + ### Part A zero extend bitfield ### > > I like that, as BitAnd(value, mask) is a lot more canonical throughout the > compiler. > But I just checked, and your pattern for sbfiz looks for the ZShr(Shl(value, > amount), amount) pattern. > Have you tried running testInsertSignedBitfieldInZero64 on ARM64 ? I would > expect it to fail until you replace the pattern for sbfiz in B3LowerToAir. Thanks for the review. That's a good question. The pattern of sbfiz is: ((src << amount) >> amount) << lsb where the right shift is signed. And the reduction rule introduced in this patch is an unsigned right shift. Turn this: ZShr(Shl(value, amount)), amount) Into this: BitAnd(value, mask) > > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:1482 > > + uint64_t mask = width == datasize ? -1ULL : (1ULL << width) - 1ULL; > > nitpick: instead of `-1ULL` on the true side, I would put > std::numeric_limits<uint64_t>::max(). It is almost certainly equivalent, but > marking a negative number with U(unsigned)LL seems weird to me. I'll update all of them. Great point!
Yijia Huang
Comment 13 2021-06-30 10:59:27 PDT
(In reply to Saam Barati from comment #11) > Comment on attachment 432600 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=432600&action=review > > > Source/JavaScriptCore/ChangeLog:50 > > + Int @7 = ZShr(@1, @5)) > > @5 -> @6 > > > Source/JavaScriptCore/ChangeLog:51 > > + Int @8 = BitOr(@7, @6) > > @6 -> @5 > > > Source/JavaScriptCore/b3/B3LowerToAir.cpp:2860 > > + commitInternal(left->child(0)); > > + commitInternal(left); > > + commitInternal(right); > > Why is this valid to do? We never check canBeInternal. Since we're using "is > locked" checks, isn't that enough to just grab the temp, but not commit > internal? > > > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:1482 > > + uint64_t mask = width == datasize ? -1ULL : (1ULL << width) - 1ULL; > > can we use numeric_limits<uint64_t>::max instead of "-1ULL" > > also, if "width == datasize", can't we just replace ourselves with "value"? Thanks for the review. Working on them.
Yijia Huang
Comment 14 2021-06-30 11:26:58 PDT
Robin Morisset
Comment 15 2021-06-30 13:13:57 PDT
Comment on attachment 432613 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=432613&action=review r=me with a minor comment. Thank you for the explanation about sbfiz, I had missed that it uses SShr instead of ZShr. I'll cq+ once all the bots are green (unless you can/want to do it yourself). > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:1491 > + replaceWithIdentity(m_value->child(0)->child(0)); I don't think this is needed: in the case where amount1 == 0,the shifts will already be replaced by Identity in handleShiftAmount().
Yijia Huang
Comment 16 2021-06-30 13:22:16 PDT
Yijia Huang
Comment 17 2021-06-30 13:23:12 PDT
(In reply to Robin Morisset from comment #15) > Comment on attachment 432613 [details] > Patch > > > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:1491 > > + replaceWithIdentity(m_value->child(0)->child(0)); > > I don't think this is needed: in the case where amount1 == 0,the shifts will > already be replaced by Identity in handleShiftAmount(). Indeed, thanks for pointing it out. Updated.
Robin Morisset
Comment 18 2021-07-01 10:09:18 PDT
Comment on attachment 432621 [details] Patch r=me; cq=me
EWS
Comment 19 2021-07-01 10:25:33 PDT
Committed r279470 (239324@main): <https://commits.webkit.org/239324@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 432621 [details].
Note You need to log in before you can comment on or make changes to this bug.