Closed
Bug 1084319
Opened 11 years ago
Closed 11 years ago
SIMD: inline Clamp
Categories
(Core :: JavaScript Engine: JIT, defect)
Tracking
()
RESOLVED
WONTFIX
mozilla40
| Tracking | Status | |
|---|---|---|
| firefox40 | --- | fixed |
People
(Reporter: bbouvier, Assigned: bbouvier)
References
Details
Attachments
(1 file)
|
6.60 KB,
patch
|
Details | Diff | Splinter Review |
So it was apparently agreed that SIMD.float32x4.clamp should be kept. As a reminder:
SIMD.float32x4.clamp(x, low, high) = min(max(x[i], low[i]), high[i])
Now, the rationale behind having a separate instruction for that is to behave differently than SIMD.float32x4.min/max, in particular in the case of NaNs and maybe -0 vs +0 (?)
Dan, how should clamp behave wrt NaN and -0 vs +0?
| Assignee | ||
Updated•11 years ago
|
Flags: needinfo?(sunfish)
Comment 1•11 years ago
|
||
I had previously requested that we postpone thinking about clamp until we settle on how min and max should behave. There now seems to be some momentum behind the plan to make min and max follow Math.min and Math.max semantics, as it's useful and what many people find most intuitive, and to also have IEEE-754-style minNum and maxNum functions, because IEEE-754, and because there are some important use cases for them.
And in view of this, I now am contemplating recommending we remove clamp from the spec. clamp makes a few optimizations easier, but at the same time, in the spec we'd probably have to include "if (low > high) return NaN", which a user-defined or library-defined clamp could more easily skip. And, it's difficult to decide what to do when x is NaN: return NaN to avoid squelching an exception, or return low or high to maintain a stricter invariant? I haven't found agreement among prior art -- most contexts where clamp is used don't give NaN much thought. Any thoughts here before I take this proposal forward?
Flags: needinfo?(sunfish)
| Assignee | ||
Comment 2•11 years ago
|
||
This makes sense. I've suggested removing clamp as well in [0], but Luke was the one who said we should keep it, to not depend on min/max semantics. Luke, any strong motivation for keeping this operator?
[0] https://github.com/johnmccutchan/ecmascript_simd/issues/68
Flags: needinfo?(luke)
| Assignee | ||
Comment 4•11 years ago
|
||
Let's morph this into inlining clamp in Ion, as this is now trivial by using two simd comp and two selects.
| Assignee | ||
Comment 5•11 years ago
|
||
This patch makes me think we really don't need clamp in the spec and would need a library apart from the polyfill, to illustrate how to use primary operations, but oh well.
Attachment #8582450 -
Flags: review?(sunfish)
Comment 6•11 years ago
|
||
I don't recall a consensus about what to do with clamp, and can't find a discussion of it at the moment. There were discussions in which we agreed to keep it until after min/max had settled down. Have there been any discussions since min/max have now settled down?
| Assignee | ||
Comment 7•11 years ago
|
||
(In reply to Dan Gohman [:sunfish] from comment #6)
> I don't recall a consensus about what to do with clamp, and can't find a
> discussion of it at the moment. There were discussions in which we agreed to
> keep it until after min/max had settled down. Have there been any
> discussions since min/max have now settled down?
I remember asking whether we should delete it several times in the internal email thread, because 1) it can be emulated easily with other ops (as this patch shows) and 2) it doesn't map to a single processor instruction, and the conclusion was that it is useful. Maybe worth that we bring the topic back for the next face-to-face meeting? (i will very probably be in PTO all next week, so if you could bring it on the agenda please, that would be great! :))
Flags: needinfo?(sunfish)
| Assignee | ||
Comment 8•11 years ago
|
||
Here's the discussion about SIMD.clamp, which has been closed without any other comment...
https://github.com/johnmccutchan/ecmascript_simd/issues/68
The internal email thread didn't say much more about it...
The only advantage with clamp is to guarantee optimization isn't missed, but I can't imagine how the optimization opportunity could be missed? That is, SIMD.clamp should be optimized whenever the equivalent operations sequence is optimized.
Comment 9•11 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
status-firefox40:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
| Assignee | ||
Comment 10•11 years ago
|
||
Oops sorry, wrong bug number in this commit, changeset in comment 9 belongs to bug 1146363 as well :(
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 11•11 years ago
|
||
Clamp is no longer part of the core spec: https://github.com/johnmccutchan/ecmascript_simd/pull/153
Status: REOPENED → RESOLVED
Closed: 11 years ago → 11 years ago
Flags: needinfo?(sunfish)
Resolution: --- → WONTFIX
Updated•11 years ago
|
Attachment #8582450 -
Flags: review?(sunfish)
You need to log in
before you can comment on or make changes to this bug.
Description
•