瀏覽代碼

Fix incorrect failFast for Incr0

rhuanjl 4 年之前
父節點
當前提交
12184ad149
共有 3 個文件被更改,包括 21 次插入1 次删除
  1. 5 1
      lib/Backend/GlobOpt.cpp
  2. 11 0
      test/loop/MemOpIncr0.js
  3. 5 0
      test/loop/rlexe.xml

+ 5 - 1
lib/Backend/GlobOpt.cpp

@@ -1,5 +1,6 @@
 //-------------------------------------------------------------------------------------------------------
 // Copyright (C) Microsoft Corporation and contributors. All rights reserved.
+// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 #include "Backend.h"
@@ -2364,7 +2365,10 @@ GlobOpt::CollectMemOpInfo(IR::Instr *instrBegin, IR::Instr *instr, Value *src1Va
             // Line #2: s3(s1) = Ld_A   s4(s2)
             // do not consider line #2 as a violating instr
             (instr->m_opcode == Js::OpCode::Ld_I4 &&
-                prevInstr && (prevInstr->m_opcode == Js::OpCode::Add_I4 || prevInstr->m_opcode == Js::OpCode::Sub_I4) &&
+                // note Ld_A is for the case where the add was 0
+                prevInstr && (prevInstr->m_opcode == Js::OpCode::Add_I4 ||
+                              prevInstr->m_opcode == Js::OpCode::Sub_I4 ||
+                              prevInstr->m_opcode == Js::OpCode::Ld_A   ) &&
                 instr->GetSrc1()->IsRegOpnd() &&
                 instr->GetDst()->IsRegOpnd() &&
                 prevInstr->GetDst()->IsRegOpnd() &&

+ 11 - 0
test/loop/MemOpIncr0.js

@@ -0,0 +1,11 @@
+//-------------------------------------------------------------------------------------------------------
+// Copyright (C) Microsoft. All rights reserved.
+// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+//-------------------------------------------------------------------------------------------------------
+
+for (let v3 = -65537; v3 < 3; v3 = v3 + 0) {
+    const v4 = v3++;
+}
+
+print("pass");

+ 5 - 0
test/loop/rlexe.xml

@@ -60,4 +60,9 @@
       <baseline>MemOp.baseline</baseline>
     </default>
   </test>
+    <test>
+    <default>
+      <files>MemOpIncr0.js</files>
+    </default>
+  </test>
 </regress-exe>