asm-js / validator

A reference validator for asm.js.
Apache License 2.0
1.78k stars 148 forks source link

decide whether to allow float for conditionals #16

Closed dherman closed 11 years ago

dherman commented 11 years ago

C allows floats to be used as conditionals. Decide whether we should allow that too, in which case the conditionals in the type checker should check for \number rather than \int.

dherman commented 11 years ago

According to Alon, if (f) is the same as if (f != 0.0f), which in LLVM looks like

%2 = fcmp ne f32 %1, 0
br i1 %2 [..]

In Emscripten this translates to

$2 = $1 != 0;
if ($2)

and then gets optimized to

if ($1 != 0)

So floats are never used for conditionals.