summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ast/ExpressionAnalyzer.cpp4
-rw-r--r--test/passes/code-folding.txt28
-rw-r--r--test/passes/code-folding.wast33
3 files changed, 64 insertions, 1 deletions
diff --git a/src/ast/ExpressionAnalyzer.cpp b/src/ast/ExpressionAnalyzer.cpp
index 8a372c2db..3556fcdd5 100644
--- a/src/ast/ExpressionAnalyzer.cpp
+++ b/src/ast/ExpressionAnalyzer.cpp
@@ -252,7 +252,9 @@ bool ExpressionAnalyzer::flexibleEqual(Expression* left, Expression* right, Expr
break;
}
case Expression::Id::ConstId: {
- CHECK(Const, value);
+ if (!left->cast<Const>()->value.bitwiseEqual(right->cast<Const>()->value)) {
+ return false;
+ }
break;
}
case Expression::Id::UnaryId: {
diff --git a/test/passes/code-folding.txt b/test/passes/code-folding.txt
index 9143b9615..a3c3f664c 100644
--- a/test/passes/code-folding.txt
+++ b/test/passes/code-folding.txt
@@ -1,6 +1,7 @@
(module
(type $13 (func (param f32)))
(type $1 (func))
+ (type $2 (func (result f32)))
(table 282 282 anyfunc)
(memory $0 1 1)
(func $0 (type $1)
@@ -21,4 +22,31 @@
)
)
)
+ (func $negative-zero (type $2) (result f32)
+ (if (result f32)
+ (i32.const 0)
+ (block $label$0 (result f32)
+ (f32.const 0)
+ )
+ (block $label$1 (result f32)
+ (f32.const -0)
+ )
+ )
+ )
+ (func $negative-zero-b (type $2) (result f32)
+ (drop
+ (i32.const 0)
+ )
+ (block $label$0 (result f32)
+ (f32.const -0)
+ )
+ )
+ (func $negative-zero-c (type $2) (result f32)
+ (drop
+ (i32.const 0)
+ )
+ (block $label$0 (result f32)
+ (f32.const 0)
+ )
+ )
)
diff --git a/test/passes/code-folding.wast b/test/passes/code-folding.wast
index 2310f9721..ca1768c16 100644
--- a/test/passes/code-folding.wast
+++ b/test/passes/code-folding.wast
@@ -19,5 +19,38 @@
)
)
)
+ (func $negative-zero (result f32)
+ (if (result f32)
+ (i32.const 0)
+ (block $label$0 (result f32)
+ (f32.const 0)
+ )
+ (block $label$1 (result f32)
+ (f32.const -0)
+ )
+ )
+ )
+ (func $negative-zero-b (result f32)
+ (if (result f32)
+ (i32.const 0)
+ (block $label$0 (result f32)
+ (f32.const -0)
+ )
+ (block $label$1 (result f32)
+ (f32.const -0)
+ )
+ )
+ )
+ (func $negative-zero-c (result f32)
+ (if (result f32)
+ (i32.const 0)
+ (block $label$0 (result f32)
+ (f32.const 0)
+ )
+ (block $label$1 (result f32)
+ (f32.const 0)
+ )
+ )
+ )
)