IonMonkey should fold 0-x to -x.
Categories
(Core :: JavaScript Engine: JIT, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox49 | --- | affected |
People
(Reporter: yury, Assigned: abhishekcs, Mentored)
References
(Blocks 2 open bugs)
Details
(Keywords: perf)
Attachments
(2 files, 1 obsolete file)
4.69 KB,
patch
|
Details | Diff | Splinter Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
Comment 1•8 years ago
|
||
Comment 2•8 years ago
|
||
Comment 3•8 years ago
|
||
Comment 4•8 years ago
|
||
Comment 5•8 years ago
|
||
Comment 6•8 years ago
|
||
Updated•8 years ago
|
Comment 7•8 years ago
|
||
Comment 8•8 years ago
|
||
Comment 9•8 years ago
|
||
Updated•3 years ago
|
Comment 10•3 years ago
|
||
The bug assignee didn't login in Bugzilla in the last 7 months.
:sdetar, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 11•3 years ago
|
||
We want this for Wasm and it blocks the appropriate bug.
Assignee | ||
Comment 12•2 years ago
|
||
Updated•2 years ago
|
Assignee | ||
Comment 13•2 years ago
|
||
Hi,
Decided to have a go at this. I did the smallest possible change I could understand and seemed to work from some initial testing. I am unsure about -
- What sort of testing/tests I need to add and where.
- How truncation works for MIR instructions. Some of the other folds seem to check if the
isTruncate
returnstrue
for the original instruction and if so pass the output of the folded operation toMTruncateToInt32
. I'm not sure if I need to do that for this optimization. - Since the earlier conversation on this thread mentioned only Int32 I have handled the Int32 case for now. But I feel like this optimization should be applicable for the Int64 case too ?
Comment 14•2 years ago
|
||
Thanks a lot for the patch!
I see Lars already fixed this for the Wasm case in comment 0 in the LIR backend in bug 1710403. For JS, I think we shouldn't fold 0 - x
to -1 * x
because there's a subtle difference in behavior: 0 - 0 ==> +0
, but -1 * 0 ==> -0
. What this means it that if we fold 0 - x
to -1 * x
, we would now trigger a bailout (deoptimization) if x == 0
(because the result, -0
, doesn't fit in an int32) where we didn't have a bailout before.
For cases where we don't care about -0
, for example (0 - x)|0
, the optimization added in bug 1710403 already kicks in and we generate a negl
instruction.
Given all this, I don't think there's anything left to do here unfortunately :/
Updated•2 years ago
|
Assignee | ||
Comment 16•2 years ago
|
||
Makes sense. Thanks for the explanation/clarification!
Description
•