From 1c292f3fbe56691010607714a326eee5317e455c Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sat, 25 Nov 2023 17:23:50 +0100 Subject: [PATCH] Fix calculating comparison in constant propagation --- .../org/teavm/model/optimization/GlobalValueNumbering.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/teavm/model/optimization/GlobalValueNumbering.java b/core/src/main/java/org/teavm/model/optimization/GlobalValueNumbering.java index 152284762..f9899f9b1 100644 --- a/core/src/main/java/org/teavm/model/optimization/GlobalValueNumbering.java +++ b/core/src/main/java/org/teavm/model/optimization/GlobalValueNumbering.java @@ -465,7 +465,7 @@ public class GlobalValueNumbering implements MethodOptimization { } break; case COMPARE: - evaluatedConstant = Float.compare(p, q); + evaluatedConstant = p > q ? 1 : p < q ? -1 : p == q ? 0 : 1; break; case AND: case OR: @@ -501,7 +501,7 @@ public class GlobalValueNumbering implements MethodOptimization { } break; case COMPARE: - evaluatedConstant = Double.compare(p, q); + evaluatedConstant = p > q ? 1 : p < q ? -1 : p == q ? 0 : 1; break; case AND: case OR: