Skip to content

Commit 842077d

Browse files
committed
[MERGE #5717 @nhat-nguyen] Only do float type specialization if both sources are number
Merge pull request #5717 from nhat-nguyen:floattypespecfix Fix a bug where we try to type specialize non-numbers to floats
2 parents e1583ae + 1c3ea7e commit 842077d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/Backend/GlobOpt.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -10648,6 +10648,11 @@ GlobOpt::TypeSpecializeFloatBinary(IR::Instr *instr, Value *src1Val, Value *src2
1064810648
case Js::OpCode::CmGe_A:
1064910649
case Js::OpCode::CmGt_A:
1065010650
{
10651+
if (src1Val->GetValueInfo()->IsNotNumber() || src2Val->GetValueInfo()->IsNotNumber())
10652+
{
10653+
return false;
10654+
}
10655+
1065110656
convertDstToBool = true;
1065210657
break;
1065310658
}

test/Basics/FloatComparison.js

+17
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ var tests = [
6363
assert.isFalse({} < 0.5);
6464
assert.isFalse({} <= 0.5);
6565
}
66+
},
67+
{
68+
name: "No float type specialization when operands are not number",
69+
body: function() {
70+
function test0() {
71+
var func2 = function () {
72+
return f32[1];
73+
};
74+
var f32 = new Float32Array();
75+
var f = 100;
76+
for (let i = 0; i < f; i++) {
77+
var id41 = 'caller';
78+
({ 18: func2() === 'caller' });
79+
}
80+
}
81+
test0();
82+
}
6683
}
6784
];
6885

0 commit comments

Comments
 (0)