summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJF Bastien <jfb@chromium.org>2016-02-05 05:11:50 -0800
committerJF Bastien <jfb@chromium.org>2016-02-05 05:11:50 -0800
commit7459e5af01fbe3a8e75e73783794b4cdffda34e9 (patch)
treeaae2c28eb1cc465a4582208d6c713584a51a1bcf
parent8f67b6e27a38c93fbca7f3c44a88889b3896952f (diff)
downloadbinaryen-7459e5af01fbe3a8e75e73783794b4cdffda34e9.tar.gz
binaryen-7459e5af01fbe3a8e75e73783794b4cdffda34e9.tar.bz2
binaryen-7459e5af01fbe3a8e75e73783794b4cdffda34e9.zip
Fix select
The ordering changed in: https://github.com/WebAssembly/spec/pull/221 Which changed the spec tests, breaking sexpr-wasm because it pulls in the spec tests. This was then fixed: https://github.com/WebAssembly/sexpr-wasm-prototype/commit/23dc368148fc7827a603e3853f5a40287eb9effe Which in turn breaks when binaryen feeds sexpr-wasm .wast files with the old select operand ordering. Note that this PR has new failures when running the torture tests in binaryen-shell: the order of evaluation is correct in binaryen-shell but isn't emitted properly by LLVM in the .s files. This will require another patch to fix LLVM.
-rw-r--r--src/asm2wasm.h2
-rw-r--r--src/s2wasm.h3
-rw-r--r--src/wasm-interpreter.h6
-rw-r--r--src/wasm-s-parser.h6
-rw-r--r--src/wasm.h6
-rw-r--r--src/wasm2asm.h22
-rw-r--r--test/llvm_autogenerated/legalize.wast492
-rw-r--r--test/llvm_autogenerated/select.wast24
-rw-r--r--test/s2wasm_known_binaryen_shell_test_failures.txt11
m---------test/spec0
-rw-r--r--test/unit.2asm.js2
-rw-r--r--test/unit.fromasm8
-rw-r--r--test/unit.wast8
-rw-r--r--test/unit.wast.fromBinary8
m---------test/waterfall0
15 files changed, 305 insertions, 293 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index d56bf0cce..22db2636a 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -1109,9 +1109,9 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
flip->right = get();
flip->type = i32;
auto select = allocator.alloc<Select>();
- select->condition = isNegative;
select->ifTrue = flip;
select->ifFalse = get();
+ select->condition = isNegative;
select->type = i32;
block->list.push_back(select);
block->type = i32;
diff --git a/src/s2wasm.h b/src/s2wasm.h
index 275cf6a9c..f800e193b 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -688,9 +688,10 @@ class S2WasmBuilder {
skipComma();
auto curr = allocator.alloc<Select>();
auto inputs = getInputs(3);
- curr->condition = inputs[0];
curr->ifTrue = inputs[1];
curr->ifFalse = inputs[2];
+ curr->condition = inputs[0];
+ assert(curr->condition->type == i32);
curr->type = type;
setOutput(curr, assign);
};
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 022dd04bc..3f9427ed7 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -620,13 +620,13 @@ private:
}
Flow visitSelect(Select *curr) {
NOTE_ENTER("Select");
- Flow condition = visit(curr->condition);
- if (condition.breaking()) return condition;
- NOTE_EVAL1(condition.value);
Flow ifTrue = visit(curr->ifTrue);
if (ifTrue.breaking()) return ifTrue;
Flow ifFalse = visit(curr->ifFalse);
if (ifFalse.breaking()) return ifFalse;
+ Flow condition = visit(curr->condition);
+ if (condition.breaking()) return condition;
+ NOTE_EVAL1(condition.value);
return condition.value.geti32() ? ifTrue : ifFalse; // ;-)
}
Flow visitReturn(Return *curr) {
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index e2a880e51..64dc6a454 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -633,9 +633,9 @@ private:
Expression* makeSelect(Element& s, WasmType type) {
auto ret = allocator.alloc<Select>();
- ret->condition = parseExpression(s[1]);
- ret->ifTrue = parseExpression(s[2]);
- ret->ifFalse = parseExpression(s[3]);
+ ret->ifTrue = parseExpression(s[1]);
+ ret->ifFalse = parseExpression(s[2]);
+ ret->condition = parseExpression(s[3]);
ret->type = type;
return ret;
}
diff --git a/src/wasm.h b/src/wasm.h
index b9d0d6822..893c777c4 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -911,15 +911,15 @@ class Select : public Expression {
public:
Select() : Expression(SelectId) {}
- Expression *condition, *ifTrue, *ifFalse;
+ Expression *ifTrue, *ifFalse, *condition;
std::ostream& doPrint(std::ostream &o, unsigned indent) {
o << '(';
prepareColor(o) << printWasmType(type) << ".select";
incIndent(o, indent);
- printFullLine(o, indent, condition);
printFullLine(o, indent, ifTrue);
printFullLine(o, indent, ifFalse);
+ printFullLine(o, indent, condition);
return decIndent(o, indent);
}
@@ -1447,9 +1447,9 @@ struct ChildWalker : public WasmWalkerBase<ChildWalker<ParentType>> {
parent.walk(curr->right);
}
void visitSelect(Select *curr) {
- parent.walk(curr->condition);
parent.walk(curr->ifTrue);
parent.walk(curr->ifFalse);
+ parent.walk(curr->condition);
}
void visitReturn(Return *curr) {
parent.walk(curr->value);
diff --git a/src/wasm2asm.h b/src/wasm2asm.h
index c87e81eec..d8ac6376e 100644
--- a/src/wasm2asm.h
+++ b/src/wasm2asm.h
@@ -463,7 +463,7 @@ void Wasm2AsmBuilder::scanFunctionBody(Expression* curr) {
}
}
void visitSelect(Select *curr) {
- if (parent->isStatement(curr->condition) || parent->isStatement(curr->ifTrue) || parent->isStatement(curr->ifFalse)) {
+ if (parent->isStatement(curr->ifTrue) || parent->isStatement(curr->ifFalse) || parent->isStatement(curr->condition)) {
parent->setStatement(curr);
}
}
@@ -1057,32 +1057,32 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) {
}
Ref visitSelect(Select *curr) {
if (isStatement(curr)) {
- ScopedTemp tempCondition(i32, parent);
- GetLocal fakeCondition;
- fakeCondition.name = tempCondition.getName();
ScopedTemp tempIfTrue(curr->ifTrue->type, parent);
GetLocal fakeLocalIfTrue;
fakeLocalIfTrue.name = tempIfTrue.getName();
ScopedTemp tempIfFalse(curr->ifFalse->type, parent);
GetLocal fakeLocalIfFalse;
fakeLocalIfFalse.name = tempIfFalse.getName();
+ ScopedTemp tempCondition(i32, parent);
+ GetLocal fakeCondition;
+ fakeCondition.name = tempCondition.getName();
Select fakeSelect = *curr;
- fakeSelect.condition = &fakeCondition;
fakeSelect.ifTrue = &fakeLocalIfTrue;
fakeSelect.ifFalse = &fakeLocalIfFalse;
- Ref ret = blockify(visitAndAssign(curr->condition, tempCondition));
- flattenAppend(ret, visitAndAssign(curr->ifTrue, tempIfTrue));
+ fakeSelect.condition = &fakeCondition;
+ Ref ret = blockify(visitAndAssign(curr->ifTrue, tempIfTrue));
flattenAppend(ret, visitAndAssign(curr->ifFalse, tempIfFalse));
+ flattenAppend(ret, visitAndAssign(curr->condition, tempCondition));
flattenAppend(ret, visitAndAssign(&fakeSelect, result));
return ret;
}
// normal select
- Ref condition = visit(curr->condition, EXPRESSION_RESULT);
Ref ifTrue = visit(curr->ifTrue, EXPRESSION_RESULT);
Ref ifFalse = visit(curr->ifFalse, EXPRESSION_RESULT);
- ScopedTemp tempCondition(i32, parent),
- tempIfTrue(curr->type, parent),
- tempIfFalse(curr->type, parent);
+ Ref condition = visit(curr->condition, EXPRESSION_RESULT);
+ ScopedTemp tempIfTrue(curr->type, parent),
+ tempIfFalse(curr->type, parent),
+ tempCondition(i32, parent);
return
ValueBuilder::makeSeq(
ValueBuilder::makeAssign(tempCondition.getAstName(), condition),
diff --git a/test/llvm_autogenerated/legalize.wast b/test/llvm_autogenerated/legalize.wast
index d2681356a..3770fa482 100644
--- a/test/llvm_autogenerated/legalize.wast
+++ b/test/llvm_autogenerated/legalize.wast
@@ -2805,26 +2805,8 @@
(i32.const 8)
)
(i64.select
- (set_local $$168
- (i64.lt_u
- (get_local $$17)
- (i64.const 512)
- )
- )
(i64.select
- (set_local $$167
- (i64.lt_u
- (get_local $$17)
- (i64.const 256)
- )
- )
(i64.select
- (set_local $$166
- (i64.lt_u
- (get_local $$17)
- (i64.const 128)
- )
- )
(i64.load align=8
(i32.add
(get_local $$311)
@@ -2832,26 +2814,44 @@
)
)
(i64.const 0)
+ (set_local $$166
+ (i64.lt_u
+ (get_local $$17)
+ (i64.const 128)
+ )
+ )
)
(i64.const 0)
+ (set_local $$167
+ (i64.lt_u
+ (get_local $$17)
+ (i64.const 256)
+ )
+ )
)
(i64.const 0)
+ (set_local $$168
+ (i64.lt_u
+ (get_local $$17)
+ (i64.const 512)
+ )
+ )
)
)
(i64.store align=8
(get_local $$0)
(i64.select
- (get_local $$168)
(i64.select
- (get_local $$167)
(i64.select
- (get_local $$166)
(get_local $$152)
(i64.const 0)
+ (get_local $$166)
)
(i64.const 0)
+ (get_local $$167)
)
(i64.const 0)
+ (get_local $$168)
)
)
(i64.store align=8
@@ -2860,29 +2860,29 @@
(i32.const 24)
)
(i64.select
- (get_local $$168)
(i64.select
- (get_local $$167)
(i64.select
- (set_local $$165
- (i64.eq
- (get_local $$17)
- (i64.const 0)
- )
- )
(get_local $$4)
(i64.select
- (get_local $$166)
(i64.or
(get_local $$149)
(get_local $$150)
)
(get_local $$151)
+ (get_local $$166)
+ )
+ (set_local $$165
+ (i64.eq
+ (get_local $$17)
+ (i64.const 0)
+ )
)
)
(i64.const 0)
+ (get_local $$167)
)
(i64.const 0)
+ (get_local $$168)
)
)
(i64.store align=8
@@ -2891,24 +2891,24 @@
(i32.const 16)
)
(i64.select
- (get_local $$168)
(i64.select
- (get_local $$167)
(i64.select
- (get_local $$165)
(get_local $$3)
(i64.select
- (get_local $$166)
(i64.or
(get_local $$146)
(get_local $$147)
)
(get_local $$148)
+ (get_local $$166)
)
+ (get_local $$165)
)
(i64.const 0)
+ (get_local $$167)
)
(i64.const 0)
+ (get_local $$168)
)
)
(i64.store align=8
@@ -2917,61 +2917,61 @@
(i32.const 56)
)
(i64.select
- (get_local $$168)
(i64.select
- (get_local $$165)
(get_local $$8)
(i64.select
- (get_local $$167)
(i64.or
(i64.select
- (get_local $$165)
(get_local $$8)
(i64.select
- (get_local $$166)
(i64.or
(get_local $$132)
(get_local $$133)
)
(get_local $$134)
+ (get_local $$166)
)
+ (get_local $$165)
)
(i64.select
+ (get_local $$135)
+ (i64.const 0)
(set_local $$164
(i64.lt_u
(get_local $$172)
(i64.const 128)
)
)
- (get_local $$135)
- (i64.const 0)
)
)
(i64.select
- (set_local $$153
- (i64.eq
- (get_local $$176)
- (i64.const 0)
- )
- )
(get_local $$4)
(i64.select
+ (i64.or
+ (get_local $$130)
+ (get_local $$129)
+ )
+ (get_local $$131)
(set_local $$163
(i64.lt_u
(get_local $$176)
(i64.const 128)
)
)
- (i64.or
- (get_local $$130)
- (get_local $$129)
+ )
+ (set_local $$153
+ (i64.eq
+ (get_local $$176)
+ (i64.const 0)
)
- (get_local $$131)
)
)
+ (get_local $$167)
)
+ (get_local $$165)
)
(i64.const 0)
+ (get_local $$168)
)
)
(i64.store align=8
@@ -2980,46 +2980,46 @@
(i32.const 48)
)
(i64.select
- (get_local $$168)
(i64.select
- (get_local $$165)
(get_local $$7)
(i64.select
- (get_local $$167)
(i64.or
(i64.select
- (get_local $$165)
(get_local $$7)
(i64.select
- (get_local $$166)
(i64.or
(get_local $$125)
(get_local $$126)
)
(get_local $$127)
+ (get_local $$166)
)
+ (get_local $$165)
)
(i64.select
- (get_local $$164)
(get_local $$128)
(i64.const 0)
+ (get_local $$164)
)
)
(i64.select
- (get_local $$153)
(get_local $$3)
(i64.select
- (get_local $$163)
(i64.or
(get_local $$123)
(get_local $$122)
)
(get_local $$124)
+ (get_local $$163)
)
+ (get_local $$153)
)
+ (get_local $$167)
)
+ (get_local $$165)
)
(i64.const 0)
+ (get_local $$168)
)
)
(i64.store align=8
@@ -3028,44 +3028,44 @@
(i32.const 40)
)
(i64.select
- (get_local $$168)
(i64.select
- (get_local $$165)
(get_local $$6)
(i64.select
- (get_local $$167)
(i64.or
(i64.select
- (get_local $$166)
(get_local $$144)
(i64.const 0)
+ (get_local $$166)
)
(i64.select
- (set_local $$162
- (i64.eq
- (get_local $$172)
- (i64.const 0)
- )
- )
(get_local $$2)
(i64.select
- (get_local $$164)
(i64.or
(get_local $$141)
(get_local $$142)
)
(get_local $$143)
+ (get_local $$164)
+ )
+ (set_local $$162
+ (i64.eq
+ (get_local $$172)
+ (i64.const 0)
+ )
)
)
)
(i64.select
- (get_local $$163)
(get_local $$145)
(i64.const 0)
+ (get_local $$163)
)
+ (get_local $$167)
)
+ (get_local $$165)
)
(i64.const 0)
+ (get_local $$168)
)
)
(i64.store align=8
@@ -3074,39 +3074,39 @@
(i32.const 32)
)
(i64.select
- (get_local $$168)
(i64.select
- (get_local $$165)
(get_local $$5)
(i64.select
- (get_local $$167)
(i64.or
(i64.select
- (get_local $$166)
(get_local $$139)
(i64.const 0)
+ (get_local $$166)
)
(i64.select
- (get_local $$162)
(get_local $$1)
(i64.select
- (get_local $$164)
(i64.or
(get_local $$136)
(get_local $$137)
)
(get_local $$138)
+ (get_local $$164)
)
+ (get_local $$162)
)
)
(i64.select
- (get_local $$163)
(get_local $$140)
(i64.const 0)
+ (get_local $$163)
)
+ (get_local $$167)
)
+ (get_local $$165)
)
(i64.const 0)
+ (get_local $$168)
)
)
(i64.store align=8
@@ -3115,138 +3115,138 @@
(i32.const 120)
)
(i64.select
- (get_local $$165)
(get_local $$16)
(i64.select
- (get_local $$168)
(i64.or
(i64.select
- (get_local $$165)
(get_local $$16)
(i64.select
- (get_local $$167)
(i64.or
(i64.select
- (get_local $$165)
(get_local $$16)
(i64.select
- (get_local $$166)
(i64.or
(get_local $$51)
(get_local $$52)
)
(get_local $$53)
+ (get_local $$166)
)
+ (get_local $$165)
)
(i64.select
- (get_local $$164)
(get_local $$54)
(i64.const 0)
+ (get_local $$164)
)
)
(i64.select
- (get_local $$153)
(get_local $$12)
(i64.select
- (get_local $$163)
(i64.or
(get_local $$49)
(get_local $$48)
)
(get_local $$50)
+ (get_local $$163)
)
+ (get_local $$153)
)
+ (get_local $$167)
)
+ (get_local $$165)
)
(i64.select
- (set_local $$161
- (i64.lt_u
- (get_local $$171)
- (i64.const 256)
- )
- )
(i64.select
+ (get_local $$55)
+ (i64.const 0)
(set_local $$160
(i64.lt_u
(get_local $$171)
(i64.const 128)
)
)
- (get_local $$55)
- (i64.const 0)
)
(i64.const 0)
+ (set_local $$161
+ (i64.lt_u
+ (get_local $$171)
+ (i64.const 256)
+ )
+ )
)
)
(i64.select
- (get_local $$158)
(get_local $$8)
(i64.select
- (set_local $$159
- (i64.lt_u
- (get_local $$180)
- (i64.const 256)
- )
- )
(i64.or
(i64.select
- (set_local $$158
- (i64.eq
- (get_local $$180)
- (i64.const 0)
- )
- )
(get_local $$8)
(i64.select
+ (i64.or
+ (get_local $$45)
+ (get_local $$175)
+ )
+ (get_local $$46)
(set_local $$157
(i64.lt_u
(get_local $$180)
(i64.const 128)
)
)
- (i64.or
- (get_local $$45)
- (get_local $$175)
+ )
+ (set_local $$158
+ (i64.eq
+ (get_local $$180)
+ (i64.const 0)
)
- (get_local $$46)
)
)
(i64.select
+ (get_local $$47)
+ (i64.const 0)
(set_local $$156
(i64.lt_u
(get_local $$178)
(i64.const 128)
)
)
- (get_local $$47)
- (i64.const 0)
)
)
(i64.select
- (set_local $$155
- (i64.eq
- (get_local $$182)
- (i64.const 0)
- )
- )
(get_local $$4)
(i64.select
+ (i64.or
+ (get_local $$177)
+ (get_local $$174)
+ )
+ (get_local $$179)
(set_local $$154
(i64.lt_u
(get_local $$182)
(i64.const 128)
)
)
- (i64.or
- (get_local $$177)
- (get_local $$174)
+ )
+ (set_local $$155
+ (i64.eq
+ (get_local $$182)
+ (i64.const 0)
)
- (get_local $$179)
+ )
+ )
+ (set_local $$159
+ (i64.lt_u
+ (get_local $$180)
+ (i64.const 256)
)
)
)
+ (get_local $$158)
)
+ (get_local $$168)
)
+ (get_local $$165)
)
)
(i64.store align=8
@@ -3255,98 +3255,98 @@
(i32.const 112)
)
(i64.select
- (get_local $$165)
(get_local $$15)
(i64.select
- (get_local $$168)
(i64.or
(i64.select
- (get_local $$165)
(get_local $$15)
(i64.select
- (get_local $$167)
(i64.or
(i64.select
- (get_local $$165)
(get_local $$15)
(i64.select
- (get_local $$166)
(i64.or
(get_local $$40)
(get_local $$41)
)
(get_local $$42)
+ (get_local $$166)
)
+ (get_local $$165)
)
(i64.select
- (get_local $$164)
(get_local $$43)
(i64.const 0)
+ (get_local $$164)
)
)
(i64.select
- (get_local $$153)
(get_local $$11)
(i64.select
- (get_local $$163)
(i64.or
(get_local $$38)
(get_local $$37)
)
(get_local $$39)
+ (get_local $$163)
)
+ (get_local $$153)
)
+ (get_local $$167)
)
+ (get_local $$165)
)
(i64.select
- (get_local $$161)
(i64.select
- (get_local $$160)
(get_local $$44)
(i64.const 0)
+ (get_local $$160)
)
(i64.const 0)
+ (get_local $$161)
)
)
(i64.select
- (get_local $$158)
(get_local $$7)
(i64.select
- (get_local $$159)
(i64.or
(i64.select
- (get_local $$158)
(get_local $$7)
(i64.select
- (get_local $$157)
(i64.or
(get_local $$34)
(get_local $$33)
)
(get_local $$35)
+ (get_local $$157)
)
+ (get_local $$158)
)
(i64.select
- (get_local $$156)
(get_local $$36)
(i64.const 0)
+ (get_local $$156)
)
)
(i64.select
- (get_local $$155)
(get_local $$3)
(i64.select
- (get_local $$154)
(i64.or
(get_local $$181)
(get_local $$173)
)
(get_local $$169)
+ (get_local $$154)
)
+ (get_local $$155)
)
+ (get_local $$159)
)
+ (get_local $$158)
)
+ (get_local $$168)
)
+ (get_local $$165)
)
)
(i64.store align=8
@@ -3355,101 +3355,101 @@
(i32.const 104)
)
(i64.select
- (get_local $$165)
(get_local $$14)
(i64.select
- (get_local $$168)
(i64.or
(i64.select
- (get_local $$165)
(get_local $$14)
(i64.select
- (get_local $$167)
(i64.or
(i64.select
- (get_local $$166)
(get_local $$115)
(i64.const 0)
+ (get_local $$166)
)
(i64.select
- (get_local $$162)
(get_local $$10)
(i64.select
- (get_local $$164)
(i64.or
(get_local $$112)
(get_local $$113)
)
(get_local $$114)
+ (get_local $$164)
)
+ (get_local $$162)
)
)
(i64.select
- (get_local $$163)
(get_local $$116)
(i64.const 0)
+ (get_local $$163)
)
+ (get_local $$167)
)
+ (get_local $$165)
)
(i64.select
- (get_local $$161)
(i64.select
- (set_local $$153
- (i64.eq
- (get_local $$171)
- (i64.const 0)
- )
- )
(get_local $$6)
(i64.select
- (get_local $$160)
(i64.or
(get_local $$109)
(get_local $$110)
)
(get_local $$111)
+ (get_local $$160)
+ )
+ (set_local $$153
+ (i64.eq
+ (get_local $$171)
+ (i64.const 0)
+ )
)
)
(i64.const 0)
+ (get_local $$161)
)
)
(i64.select
- (get_local $$158)
(get_local $$6)
(i64.select
- (get_local $$159)
(i64.or
(i64.select
- (get_local $$157)
(get_local $$120)
(i64.const 0)
+ (get_local $$157)
)
(i64.select
- (set_local $$155
- (i64.eq
- (get_local $$178)
- (i64.const 0)
- )
- )
(get_local $$2)
(i64.select
- (get_local $$156)
(i64.or
(get_local $$117)
(get_local $$118)
)
(get_local $$119)
+ (get_local $$156)
+ )
+ (set_local $$155
+ (i64.eq
+ (get_local $$178)
+ (i64.const 0)
+ )
)
)
)
(i64.select
- (get_local $$154)
(get_local $$121)
(i64.const 0)
+ (get_local $$154)
)
+ (get_local $$159)
)
+ (get_local $$158)
)
+ (get_local $$168)
)
+ (get_local $$165)
)
)
(i64.store align=8
@@ -3458,91 +3458,91 @@
(i32.const 96)
)
(i64.select
- (get_local $$165)
(get_local $$13)
(i64.select
- (get_local $$168)
(i64.or
(i64.select
- (get_local $$165)
(get_local $$13)
(i64.select
- (get_local $$167)
(i64.or
(i64.select
- (get_local $$166)
(get_local $$102)
(i64.const 0)
+ (get_local $$166)
)
(i64.select
- (get_local $$162)
(get_local $$9)
(i64.select
- (get_local $$164)
(i64.or
(get_local $$99)
(get_local $$100)
)
(get_local $$101)
+ (get_local $$164)
)
+ (get_local $$162)
)
)
(i64.select
- (get_local $$163)
(get_local $$103)
(i64.const 0)
+ (get_local $$163)
)
+ (get_local $$167)
)
+ (get_local $$165)
)
(i64.select
- (get_local $$161)
(i64.select
- (get_local $$153)
(get_local $$5)
(i64.select
- (get_local $$160)
(i64.or
(get_local $$96)
(get_local $$97)
)
(get_local $$98)
+ (get_local $$160)
)
+ (get_local $$153)
)
(i64.const 0)
+ (get_local $$161)
)
)
(i64.select
- (get_local $$158)
(get_local $$5)
(i64.select
- (get_local $$159)
(i64.or
(i64.select
- (get_local $$157)
(get_local $$107)
(i64.const 0)
+ (get_local $$157)
)
(i64.select
- (get_local $$155)
(get_local $$1)
(i64.select
- (get_local $$156)
(i64.or
(get_local $$104)
(get_local $$105)
)
(get_local $$106)
+ (get_local $$156)
)
+ (get_local $$155)
)
)
(i64.select
- (get_local $$154)
(get_local $$108)
(i64.const 0)
+ (get_local $$154)
)
+ (get_local $$159)
)
+ (get_local $$158)
)
+ (get_local $$168)
)
+ (get_local $$165)
)
)
(i64.store align=8
@@ -3551,74 +3551,74 @@
(i32.const 72)
)
(i64.select
- (get_local $$165)
(get_local $$10)
(i64.select
- (get_local $$168)
(i64.or
(i64.select
- (get_local $$167)
(i64.select
- (get_local $$166)
(get_local $$94)
(i64.const 0)
+ (get_local $$166)
)
(i64.const 0)
+ (get_local $$167)
)
(i64.select
- (get_local $$153)
(get_local $$2)
(i64.select
- (get_local $$161)
(i64.or
(i64.select
- (get_local $$153)
(get_local $$2)
(i64.select
- (get_local $$160)
(i64.or
(get_local $$90)
(get_local $$91)
)
(get_local $$92)
+ (get_local $$160)
)
+ (get_local $$153)
)
(i64.select
+ (get_local $$93)
+ (i64.const 0)
(set_local $$163
(i64.lt_u
(get_local $$170)
(i64.const 128)
)
)
- (get_local $$93)
- (i64.const 0)
)
)
(i64.select
- (get_local $$162)
(get_local $$6)
(i64.select
- (get_local $$164)
(i64.or
(get_local $$87)
(get_local $$88)
)
(get_local $$89)
+ (get_local $$164)
)
+ (get_local $$162)
)
+ (get_local $$161)
)
+ (get_local $$153)
)
)
(i64.select
- (get_local $$159)
(i64.select
- (get_local $$157)
(get_local $$95)
(i64.const 0)
+ (get_local $$157)
)
(i64.const 0)
+ (get_local $$159)
)
+ (get_local $$168)
)
+ (get_local $$165)
)
)
(i64.store align=8
@@ -3627,69 +3627,69 @@
(i32.const 64)
)
(i64.select
- (get_local $$165)
(get_local $$9)
(i64.select
- (get_local $$168)
(i64.or
(i64.select
- (get_local $$167)
(i64.select
- (get_local $$166)
(get_local $$85)
(i64.const 0)
+ (get_local $$166)
)
(i64.const 0)
+ (get_local $$167)
)
(i64.select
- (get_local $$153)
(get_local $$1)
(i64.select
- (get_local $$161)
(i64.or
(i64.select
- (get_local $$153)
(get_local $$1)
(i64.select
- (get_local $$160)
(i64.or
(get_local $$81)
(get_local $$82)
)
(get_local $$83)
+ (get_local $$160)
)
+ (get_local $$153)
)
(i64.select
- (get_local $$163)
(get_local $$84)
(i64.const 0)
+ (get_local $$163)
)
)
(i64.select
- (get_local $$162)
(get_local $$5)
(i64.select
- (get_local $$164)
(i64.or
(get_local $$78)
(get_local $$79)
)
(get_local $$80)
+ (get_local $$164)
)
+ (get_local $$162)
)
+ (get_local $$161)
)
+ (get_local $$153)
)
)
(i64.select
- (get_local $$159)
(i64.select
- (get_local $$157)
(get_local $$86)
(i64.const 0)
+ (get_local $$157)
)
(i64.const 0)
+ (get_local $$159)
)
+ (get_local $$168)
)
+ (get_local $$165)
)
)
(i64.store align=8
@@ -3698,81 +3698,81 @@
(i32.const 88)
)
(i64.select
- (get_local $$165)
(get_local $$12)
(i64.select
- (get_local $$168)
(i64.or
(i64.select
- (get_local $$167)
(i64.select
- (get_local $$165)
(get_local $$12)
(i64.select
- (get_local $$166)
(i64.or
(get_local $$67)
(get_local $$68)
)
(get_local $$69)
+ (get_local $$166)
)
+ (get_local $$165)
)
(i64.const 0)
+ (get_local $$167)
)
(i64.select
- (get_local $$153)
(get_local $$4)
(i64.select
- (get_local $$161)
(i64.or
(i64.select
- (get_local $$160)
(get_local $$73)
(i64.const 0)
+ (get_local $$160)
)
(i64.select
- (set_local $$162
- (i64.eq
- (get_local $$170)
- (i64.const 0)
- )
- )
(get_local $$8)
(i64.select
- (get_local $$163)
(i64.or
(get_local $$70)
(get_local $$71)
)
(get_local $$72)
+ (get_local $$163)
+ )
+ (set_local $$162
+ (i64.eq
+ (get_local $$170)
+ (i64.const 0)
+ )
)
)
)
(i64.select
- (get_local $$164)
(get_local $$74)
(i64.const 0)
+ (get_local $$164)
)
+ (get_local $$161)
)
+ (get_local $$153)
)
)
(i64.select
- (get_local $$159)
(i64.select
- (get_local $$158)
(get_local $$4)
(i64.select
- (get_local $$157)
(i64.or
(get_local $$76)
(get_local $$75)
)
(get_local $$77)
+ (get_local $$157)
)
+ (get_local $$158)
)
(i64.const 0)
+ (get_local $$159)
)
+ (get_local $$168)
)
+ (get_local $$165)
)
)
(i64.store align=8
@@ -3781,76 +3781,76 @@
(i32.const 80)
)
(i64.select
- (get_local $$165)
(get_local $$11)
(i64.select
- (get_local $$168)
(i64.or
(i64.select
- (get_local $$167)
(i64.select
- (get_local $$165)
(get_local $$11)
(i64.select
- (get_local $$166)
(i64.or
(get_local $$56)
(get_local $$57)
)
(get_local $$58)
+ (get_local $$166)
)
+ (get_local $$165)
)
(i64.const 0)
+ (get_local $$167)
)
(i64.select
- (get_local $$153)
(get_local $$3)
(i64.select
- (get_local $$161)
(i64.or
(i64.select
- (get_local $$160)
(get_local $$62)
(i64.const 0)
+ (get_local $$160)
)
(i64.select
- (get_local $$162)
(get_local $$7)
(i64.select
- (get_local $$163)
(i64.or
(get_local $$59)
(get_local $$60)
)
(get_local $$61)
+ (get_local $$163)
)
+ (get_local $$162)
)
)
(i64.select
- (get_local $$164)
(get_local $$63)
(i64.const 0)
+ (get_local $$164)
)
+ (get_local $$161)
)
+ (get_local $$153)
)
)
(i64.select
- (get_local $$159)
(i64.select
- (get_local $$158)
(get_local $$3)
(i64.select
- (get_local $$157)
(i64.or
(get_local $$65)
(get_local $$64)
)
(get_local $$66)
+ (get_local $$157)
)
+ (get_local $$158)
)
(i64.const 0)
+ (get_local $$159)
)
+ (get_local $$168)
)
+ (get_local $$165)
)
)
(set_local $$185
diff --git a/test/llvm_autogenerated/select.wast b/test/llvm_autogenerated/select.wast
index 30d1ff0b8..7c0ba89cf 100644
--- a/test/llvm_autogenerated/select.wast
+++ b/test/llvm_autogenerated/select.wast
@@ -15,108 +15,108 @@
(func $select_i32_bool (param $$0 i32) (param $$1 i32) (param $$2 i32) (result i32)
(return
(i32.select
- (get_local $$0)
(get_local $$1)
(get_local $$2)
+ (get_local $$0)
)
)
)
(func $select_i32_eq (param $$0 i32) (param $$1 i32) (param $$2 i32) (result i32)
(return
(i32.select
- (get_local $$0)
(get_local $$2)
(get_local $$1)
+ (get_local $$0)
)
)
)
(func $select_i32_ne (param $$0 i32) (param $$1 i32) (param $$2 i32) (result i32)
(return
(i32.select
- (get_local $$0)
(get_local $$1)
(get_local $$2)
+ (get_local $$0)
)
)
)
(func $select_i64_bool (param $$0 i32) (param $$1 i64) (param $$2 i64) (result i64)
(return
(i64.select
- (get_local $$0)
(get_local $$1)
(get_local $$2)
+ (get_local $$0)
)
)
)
(func $select_i64_eq (param $$0 i32) (param $$1 i64) (param $$2 i64) (result i64)
(return
(i64.select
- (get_local $$0)
(get_local $$2)
(get_local $$1)
+ (get_local $$0)
)
)
)
(func $select_i64_ne (param $$0 i32) (param $$1 i64) (param $$2 i64) (result i64)
(return
(i64.select
- (get_local $$0)
(get_local $$1)
(get_local $$2)
+ (get_local $$0)
)
)
)
(func $select_f32_bool (param $$0 i32) (param $$1 f32) (param $$2 f32) (result f32)
(return
(f32.select
- (get_local $$0)
(get_local $$1)
(get_local $$2)
+ (get_local $$0)
)
)
)
(func $select_f32_eq (param $$0 i32) (param $$1 f32) (param $$2 f32) (result f32)
(return
(f32.select
- (get_local $$0)
(get_local $$2)
(get_local $$1)
+ (get_local $$0)
)
)
)
(func $select_f32_ne (param $$0 i32) (param $$1 f32) (param $$2 f32) (result f32)
(return
(f32.select
- (get_local $$0)
(get_local $$1)
(get_local $$2)
+ (get_local $$0)
)
)
)
(func $select_f64_bool (param $$0 i32) (param $$1 f64) (param $$2 f64) (result f64)
(return
(f64.select
- (get_local $$0)
(get_local $$1)
(get_local $$2)
+ (get_local $$0)
)
)
)
(func $select_f64_eq (param $$0 i32) (param $$1 f64) (param $$2 f64) (result f64)
(return
(f64.select
- (get_local $$0)
(get_local $$2)
(get_local $$1)
+ (get_local $$0)
)
)
)
(func $select_f64_ne (param $$0 i32) (param $$1 f64) (param $$2 f64) (result f64)
(return
(f64.select
- (get_local $$0)
(get_local $$1)
(get_local $$2)
+ (get_local $$0)
)
)
)
diff --git a/test/s2wasm_known_binaryen_shell_test_failures.txt b/test/s2wasm_known_binaryen_shell_test_failures.txt
index 4a2117252..f4d60f4d8 100644
--- a/test/s2wasm_known_binaryen_shell_test_failures.txt
+++ b/test/s2wasm_known_binaryen_shell_test_failures.txt
@@ -1,3 +1,14 @@
+# select's operand ordering was (cond, true, false) and is now
+# (true, false, cond) as of:
+# https://github.com/WebAssembly/spec/pull/221
+# LLVM hasn't been updated to emit the operations in the right order yet, which
+# leads to the wrong order of execution.
+20021010-2.c.s.wast
+20060930-1.c.s.wast
+20071216-1.c.s.wast
+961125-1.c.s.wast
+pr59221.c.s.wast
+
# [trap highest > memory]
930126-1.c.s.wast
990222-1.c.s.wast
diff --git a/test/spec b/test/spec
-Subproject edd932d4700caddc40950d1405afc986eac2e4d
+Subproject ebb65f6f361d2291f4be57962053233161c4e52
diff --git a/test/unit.2asm.js b/test/unit.2asm.js
index 027d4fce5..83ff9f819 100644
--- a/test/unit.2asm.js
+++ b/test/unit.2asm.js
@@ -194,7 +194,7 @@ function asmFunc(global, env, buffer) {
block0 : {
block1 : {
asm2wasm_i32_temp = 0;
- wasm2asm_i32$0 = (wasm2asm_i32$1 = (asm2wasm_i32_temp | 0) < (0 | 0), wasm2asm_i32$2 = 0 - asm2wasm_i32_temp | 0, wasm2asm_i32$3 = asm2wasm_i32_temp, wasm2asm_i32$1 ? wasm2asm_i32$2 : wasm2asm_i32$3);
+ wasm2asm_i32$0 = (wasm2asm_i32$3 = (asm2wasm_i32_temp | 0) < (0 | 0), wasm2asm_i32$1 = 0 - asm2wasm_i32_temp | 0, wasm2asm_i32$2 = asm2wasm_i32_temp, wasm2asm_i32$3 ? wasm2asm_i32$1 : wasm2asm_i32$2);
}
x = wasm2asm_i32$0;
y = Math_abs(0.0);
diff --git a/test/unit.fromasm b/test/unit.fromasm
index 249a02a1c..59e06bf6a 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -297,15 +297,15 @@
(i32.const 0)
)
(i32.select
- (i32.lt_s
- (get_local $asm2wasm_i32_temp)
- (i32.const 0)
- )
(i32.sub
(i32.const 0)
(get_local $asm2wasm_i32_temp)
)
(get_local $asm2wasm_i32_temp)
+ (i32.lt_s
+ (get_local $asm2wasm_i32_temp)
+ (i32.const 0)
+ )
)
)
)
diff --git a/test/unit.wast b/test/unit.wast
index cde4722ef..928c30157 100644
--- a/test/unit.wast
+++ b/test/unit.wast
@@ -311,15 +311,15 @@
(i32.const 0)
)
(i32.select
- (i32.lt_s
- (get_local $asm2wasm_i32_temp)
- (i32.const 0)
- )
(i32.sub
(i32.const 0)
(get_local $asm2wasm_i32_temp)
)
(get_local $asm2wasm_i32_temp)
+ (i32.lt_s
+ (get_local $asm2wasm_i32_temp)
+ (i32.const 0)
+ )
)
)
)
diff --git a/test/unit.wast.fromBinary b/test/unit.wast.fromBinary
index 7c5e00b94..a56e5a672 100644
--- a/test/unit.wast.fromBinary
+++ b/test/unit.wast.fromBinary
@@ -314,15 +314,15 @@
(i32.const 0)
)
(i32.select
- (i32.lt_s
- (get_local $var$1)
- (i32.const 0)
- )
(i32.sub
(i32.const 0)
(get_local $var$1)
)
(get_local $var$1)
+ (i32.lt_s
+ (get_local $var$1)
+ (i32.const 0)
+ )
)
)
)
diff --git a/test/waterfall b/test/waterfall
-Subproject 02384098df5a2a83ef4f5c6399a73bac9ca175f
+Subproject 3a22e0ed5d95fa682e06542b298c03ee249fa6c