Skip to content

Add i32.eqz. - #555

Merged
sunfishcode merged 1 commit into
masterfrom
not
Mar 9, 2016
Merged

sunfishcode merged 1 commit into
masterfrom
not

Conversation

@sunfishcode

Copy link
Copy Markdown
Member

This adds a bool.not operator, consistent with the one in the binary format.

@sunfishcode sunfishcode mentioned this pull request Feb 25, 2016
@titzer

titzer commented Feb 25, 2016

Copy link
Copy Markdown

lgtm

@rossberg

Copy link
Copy Markdown
Member

Bikeshed: I know that v8-proto uses the same name, but it never struck me as particularly consistent. We decided not to have a bool type, so why should the operator name pretend otherwise?

@MikeHolman

Copy link
Copy Markdown
Member

Agreed with @rossberg-chromium. I would prefer to call i32.logicalNot or something along those lines.

@ghost

ghost commented Feb 26, 2016

Copy link
Copy Markdown

Please not i32.logicalNot because there is a common logical-not operation and this is not it!

@titzer

titzer commented Feb 26, 2016

Copy link
Copy Markdown

i32.eqz? Since it is literally x == 0?

On Fri, Feb 26, 2016 at 12:58 AM, JSStats [email protected] wrote:

Please not i32.logicalNot because there is a common logical-not operation
and this is not it!

—
Reply to this email directly or view it on GitHub
#555 (comment).

@lukewagner

Copy link
Copy Markdown
Member

I like the symmetry of i32.eqz with i32.eq so sgtm.

@sunfishcode

Copy link
Copy Markdown
Member Author

Currently we say all i32 operators are also available in i64. bool.* kind of bypassed that, but I'm not attached to it. Any preferences for adding an i64 version of this operation too for consistency, or instead for making an exception to that rule to exclude an i64 version? I don't have an opinion at present.

Also, for the shade of purple of the bikeshed, any preference for "eq0" instead of "eqz"?

@binji

binji commented Feb 26, 2016

Copy link
Copy Markdown
Member

Well, we already have i32.clz and i32.ctz, so i32.eqz seems more consistent.

If we had i64.eqz, would its return type be i32 or i64? i32 would be consistent with other comparison ops, but i64 would be consistent with other unary ops.

@jfbastien

Copy link
Copy Markdown
Member

My bikeshed is painted with stripes of i32.eqz and i64.eqz.

@titzer

titzer commented Feb 26, 2016

Copy link
Copy Markdown

I think we should only add i32.eqz (or really, just rename bool.not). After
all, i64's cannot be used in conditions directly.

On Fri, Feb 26, 2016 at 12:53 PM, Ben Smith [email protected]
wrote:

Well, we already have i32.clz and i32.ctz, so i32.eqz seems more
consistent.

If we had i64.eqz, would its return type be i32 or i64? i32 would be
consistent with other comparison ops, but i64 would be consistent with
other unary ops.

—
Reply to this email directly or view it on GitHub
#555 (comment).

@sunfishcode

Copy link
Copy Markdown
Member Author

Updated the PR to i32.eqz with a special exception to the rule for i64 operators.

@sunfishcode sunfishcode changed the title Add bool.not. Add i32.eqz. Feb 29, 2016
@rossberg

Copy link
Copy Markdown
Member

I strongly vote for including i64.eqz as well. I think it is pretty valuable to have symmetric operator sets for both types. And I can totally see it being useful for i64 as well, because zero comparisons are a frequent operation on any integer type (even more so once we have a 64-bit Wasm, where it may e.g. be used for a nullptr check).

@binji, since it is a predicate operator, i64.eqz would return bool a.k.a. i32, of course.

@binji

binji commented Feb 29, 2016

Copy link
Copy Markdown
Member

@rossberg-chromium yes, that would make the most sense. Though it does mean that i64.eqz is the only unary operator that returns a different type than its parameter (aside from the conversion operators, of course). Not that that's a reason not to do it.

@titzer

titzer commented Feb 29, 2016

Copy link
Copy Markdown

I'm fine with i64.eqz for symmetry.

On Mon, Feb 29, 2016 at 11:04 AM, Ben Smith [email protected]
wrote:

@rossberg-chromium https://github.com/rossberg-chromium yes, that would
make the most sense. Though it does mean that i64.eqz is the only unary
operator that returns a different type than its parameter (aside from the
conversion operators, of course). Not that that's a reason not to do it.

—
Reply to this email directly or view it on GitHub
#555 (comment).

@sunfishcode

Copy link
Copy Markdown
Member Author

Updated to add both i32.eqz and i64.eqz now, which appears to be the generally preferred approach.

@rossberg

rossberg commented Mar 4, 2016

Copy link
Copy Markdown
Member

Sounds good, though it somehow doesn't show up in the diff.

@sunfishcode

Copy link
Copy Markdown
Member Author

That's because AstSemantics.md just says "The same operators are available on 64-bit integers as the those available for 32-bit integers." The change to add i64.eqz was to remove the special exception I had previously added to that sentence.

@rossberg

rossberg commented Mar 4, 2016

Copy link
Copy Markdown
Member

Ah, okay, got it. LGTM

@ghost

ghost commented Mar 4, 2016

Copy link
Copy Markdown

@sunfishcode Could you check that the name of the opcode in the binary encoding is updated here too as it was missed in #587

@sunfishcode

Copy link
Copy Markdown
Member Author

i32.eqz and i64.eqz appear to have sufficient consensus; merging.

sunfishcode added a commit that referenced this pull request Mar 9, 2016
@sunfishcode
sunfishcode merged commit d678a13 into master Mar 9, 2016
@sunfishcode
sunfishcode deleted the not branch March 9, 2016 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants