Semantic of WebAssembly "select" instruction?

29 views
Skip to first unread message

Stéphane Letz

unread,
Nov 13, 2019, 2:09:19 PM11/13/19
to emscripten-discuss
Does  WebAssembly "select" instruction behaves like C/C++ (cond ? then : else),  that is compute *only* one of the two branches depending of the "cond" value? 

Thanks.

Thomas Lively

unread,
Nov 13, 2019, 2:10:20 PM11/13/19
to emscripte...@googlegroups.com
No, it unconditionally evaluates all arguments.

On Wed, Nov 13, 2019 at 11:09 AM Stéphane Letz <le...@grame.fr> wrote:
Does  WebAssembly "select" instruction behaves like C/C++ (cond ? then : else),  that is compute *only* one of the two branches depending of the "cond" value? 

Thanks.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/06055c34-5186-4f6b-92f7-eb6a9580f893%40googlegroups.com.

Stéphane Letz

unread,
Nov 13, 2019, 2:18:50 PM11/13/19
to emscripten-discuss
So, It means the (cond ? then : else) kind of semantic has to be implemented using "if" right ?


Le mercredi 13 novembre 2019 20:10:20 UTC+1, Thomas Lively a écrit :
No, it unconditionally evaluates all arguments.

On Wed, Nov 13, 2019 at 11:09 AM Stéphane Letz <le...@grame.fr> wrote:
Does  WebAssembly "select" instruction behaves like C/C++ (cond ? then : else),  that is compute *only* one of the two branches depending of the "cond" value? 

Thanks.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Thomas Lively

unread,
Nov 13, 2019, 2:37:48 PM11/13/19
to emscripte...@googlegroups.com
Yes, that's right, unless the two operands have no side effects. In that case the compiler is free to use a select because the difference is not observable.

On Wed, Nov 13, 2019 at 11:18 AM Stéphane Letz <le...@grame.fr> wrote:
So, It means the (cond ? then : else) kind of semantic has to be implemented using "if" right ?

Le mercredi 13 novembre 2019 20:10:20 UTC+1, Thomas Lively a écrit :
No, it unconditionally evaluates all arguments.

On Wed, Nov 13, 2019 at 11:09 AM Stéphane Letz <le...@grame.fr> wrote:
Does  WebAssembly "select" instruction behaves like C/C++ (cond ? then : else),  that is compute *only* one of the two branches depending of the "cond" value? 

Thanks.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/972b55b8-2508-464e-830e-def000c485c2%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages