Bug 1258632 - Distinguish signed/unsigned MDiv/MMod in GVN. r=bbouvier a=sylvestre
authorPip <pipcet@gmail.com>
Tue, 22 Mar 2016 09:41:00 +0100
changeset 325606 f4c392adb1a3fd4ec95a5229d5df6787e3fd7bdb
parent 325605 45b21b36621f18310fc8e7bde6f3110602de54af
child 325607 f78fc14ce33f92577a0d686e25f1a0d0db226b37
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier, sylvestre
bugs1258632
milestone47.0a2
Bug 1258632 - Distinguish signed/unsigned MDiv/MMod in GVN. r=bbouvier a=sylvestre Modify the congruentTo method of MDiv and MMod opcodes to take into account signedness, which is necessary for correct code generation. MozReview-Commit-ID: 5bOBSIdADgP
js/src/jit-test/tests/asm.js/testExpressions.js
js/src/jit/MIR.h
--- a/js/src/jit-test/tests/asm.js/testExpressions.js
+++ b/js/src/jit-test/tests/asm.js/testExpressions.js
@@ -388,8 +388,9 @@ for (let i = 0; i < 31; i++) {
     assertEq(f(Math.pow(2,i)), (Math.pow(2,i)/Math.pow(2,30))|0);
     assertEq(f(Math.pow(2,i+1)-1), ((Math.pow(2,i+1)-1)/Math.pow(2,30))|0);
 }
 var f = asmLink(asmCompile(USE_ASM + "function f(i) { i=i|0; i=(i&2147483647)|0; return ((((i|0)/1)|0)+i)|0; } return f;"));
 for (let i = 0; i < 31; i++) {
     assertEq(f(Math.pow(2,i)), (Math.pow(2,i) * 2)|0);
     assertEq(f(Math.pow(2,i+1) - 1), ((Math.pow(2,i+1) - 1) * 2)|0);
 }
+assertEq(asmLink(asmCompile(USE_ASM + "var g=0; function f(x, y) { x = x|0; y = y|0; g = (x>>>0)%(y>>>0)|0; return (x|0)%(y|0)|0; } return f;"))(0xff40001, 0xfff80000), 0x40001);
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -6854,16 +6854,21 @@ class MDiv : public MBinaryArithInstruct
     void collectRangeInfoPreTrunc() override;
     TruncateKind operandTruncateKind(size_t index) const override;
 
     bool writeRecoverData(CompactBufferWriter& writer) const override;
     bool canRecoverOnBailout() const override {
         return specialization_ < MIRType_Object;
     }
 
+    bool congruentTo(const MDefinition* ins) const override {
+        return MBinaryArithInstruction::congruentTo(ins) &&
+               unsigned_ == ins->toDiv()->isUnsigned();
+    }
+
     ALLOW_CLONE(MDiv)
 };
 
 class MMod : public MBinaryArithInstruction
 {
     bool unsigned_;
     bool canBeNegativeDividend_;
     bool canBePowerOfTwoDivisor_;
@@ -6932,16 +6937,21 @@ class MMod : public MBinaryArithInstruct
     bool fallible() const;
 
     void computeRange(TempAllocator& alloc) override;
     bool needTruncation(TruncateKind kind) override;
     void truncate() override;
     void collectRangeInfoPreTrunc() override;
     TruncateKind operandTruncateKind(size_t index) const override;
 
+    bool congruentTo(const MDefinition* ins) const override {
+        return MBinaryArithInstruction::congruentTo(ins) &&
+               unsigned_ == ins->toMod()->isUnsigned();
+    }
+
     ALLOW_CLONE(MMod)
 };
 
 class MConcat
   : public MBinaryInstruction,
     public MixPolicy<ConvertToStringPolicy<0>, ConvertToStringPolicy<1> >::Data
 {
     MConcat(MDefinition* left, MDefinition* right)