mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 1186226: Odin: determine comparisons' types by looking at both hand sides; r=jandem
--HG-- extra : rebase_source : 2077d7e5ab4942802a68d9f3e879f5eef9eced3f extra : amend_source : d54dd8c7a397c93e66c7bb64c26951ddc9007ee4
This commit is contained in:
parent
f78a41b060
commit
33458087e8
@ -8497,7 +8497,7 @@ CheckComparison(FunctionBuilder& f, ParseNode* comp, Type* type)
|
||||
}
|
||||
|
||||
I32 stmt;
|
||||
if (lhsType.isSigned()) {
|
||||
if (lhsType.isSigned() && rhsType.isSigned()) {
|
||||
switch (comp->getOp()) {
|
||||
case JSOP_EQ: stmt = I32::EqI32; break;
|
||||
case JSOP_NE: stmt = I32::NeI32; break;
|
||||
@ -8507,7 +8507,7 @@ CheckComparison(FunctionBuilder& f, ParseNode* comp, Type* type)
|
||||
case JSOP_GE: stmt = I32::SGeI32; break;
|
||||
default: MOZ_CRASH("unexpected comparison op");
|
||||
}
|
||||
} else if (lhsType.isUnsigned()) {
|
||||
} else if (lhsType.isUnsigned() && rhsType.isUnsigned()) {
|
||||
switch (comp->getOp()) {
|
||||
case JSOP_EQ: stmt = I32::EqI32; break;
|
||||
case JSOP_NE: stmt = I32::NeI32; break;
|
||||
|
@ -262,6 +262,9 @@ assertAsmTypeFail(USE_ASM + "function f() { var i=42,j=1.1; return +(i?i:j) } re
|
||||
assertEq(asmLink(asmCompile(USE_ASM + "function f() { var i=42,j=1.1; return +(i?+(i|0):j) } return f"))(), 42);
|
||||
assertEq(asmLink(asmCompile(USE_ASM + "function f() { var i=42,j=1; return (i?i:j)|0 } return f"))(), 42);
|
||||
|
||||
assertEq(asmLink(asmCompile(USE_ASM + "function f() { return (0 > (-(~~1) >>> 0)) | 0; } return f"))(), 0);
|
||||
assertEq(asmLink(asmCompile(USE_ASM + "function f() { return 0 < 4294967294 | 0; } return f"))(), 1);
|
||||
|
||||
var f = asmLink(asmCompile(USE_ASM + "function f(i,j) { i=i|0;j=j|0; return ((i|0)>(j|0)?(i+10)|0:(j+100)|0)|0 } return f"));
|
||||
assertEq(f(2, 4), 104);
|
||||
assertEq(f(-2, -4), 8);
|
||||
|
Loading…
Reference in New Issue
Block a user