adding a couple more hazard avoidance cases
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 22 Nov 2021 11:51:07 +0000 (11:51 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 22 Nov 2021 11:51:09 +0000 (11:51 +0000)
src/openpower/test/general/overlap_hazards.py

index fa186e0fd87c76d9dfe8665a1e01651033144612..13aa9c3ada48aaa13061615be59cc0c3be57af3c 100644 (file)
@@ -25,3 +25,44 @@ class HazardTestCase(TestAccumulatorBase):
         e.intregs[4] = 4
         e.intregs[5] = 7 # 3 plus 4 == 7
         self.add_case(Program(lst, bigendian), initial_regs, expected=e)
+
+    def case_div_add_overlap2(self):
+        lst = ["divd 3, 1, 2",
+               "mullw 5, 7, 6", # 2*4=8, overwritten later by add
+               "divd 4, 5, 6",
+               "add 5, 3, 4"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 6
+        initial_regs[2] = 2
+        initial_regs[6] = 2
+        initial_regs[7] = 4
+        e = ExpectedState(pc=16)
+        e.intregs[1] = 6
+        e.intregs[2] = 2
+        e.intregs[3] = 3 # 6 divided by 2 == 3
+        e.intregs[4] = 4 # 8 divided by 2 == 4
+        e.intregs[5] = 7 # 3 plus 4 == 7
+        e.intregs[6] = 2
+        e.intregs[7] = 4
+        self.add_case(Program(lst, bigendian), initial_regs, expected=e)
+
+    def cse_div_add_overlap_3(self):
+        lst = ["divd 3, 1, 2",
+               "mullw 5, 7, 6", # 2*4=6, overwritten later by add
+               "addi 5, 5, 2",  # add 2 to 6 = 8
+               "divd 4, 5, 6",
+               "add 5, 3, 4"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 6
+        initial_regs[2] = 2
+        initial_regs[6] = 2
+        initial_regs[7] = 4
+        e = ExpectedState(pc=16)
+        e.intregs[1] = 6
+        e.intregs[2] = 2
+        e.intregs[3] = 3 # 6 divided by 2 == 3
+        e.intregs[4] = 4 # 8 divided by 2 == 4
+        e.intregs[5] = 7 # 3 plus 4 == 7
+        e.intregs[6] = 2
+        e.intregs[7] = 4
+        self.add_case(Program(lst, bigendian), initial_regs, expected=e)