summaryrefslogtreecommitdiff
path: root/pcr/reicast-git/fix-dyna-constprop.patch
blob: c7c89b5e20fff5625364c38174b630b3b8bbbc76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
diff -Nur a/core/hw/sh4/dyna/shil.cpp b/core/hw/sh4/dyna/shil.cpp
--- a/core/hw/sh4/dyna/shil.cpp	2015-10-06 21:43:53.031336322 -0300
+++ b/core/hw/sh4/dyna/shil.cpp	2015-10-06 21:45:06.558863627 -0300
@@ -521,20 +521,39 @@
 			rv[op->rd._reg]=op->rs1._imm;
 		}
 
-		//NOT WORKING
-		//WE NEED PROPER PAGELOCKS
-		if (op->op==shop_readm && op->rs1.is_imm() && op->rd.is_r32i() && op->rd._reg<16 && op->flags==0x4 && op->rs3.is_null())
-		{
-			u32 baddr=blk->addr&0x0FFFFFFF;
+		if (0) {
+			//a more minimalistic but still broken approach for this.
+			//this is clearly a hack
+			if (op->op == shop_readm && op->rs1.is_imm() && IsOnRam(op->rs1.imm_value()))
+			{
+				u32 round = op->rs1.imm_value() & ~PAGE_MASK;
+				bool optmize_away = round == (blk->addr & ~PAGE_MASK) && (blk->addr & 0x007FFFFF) > 0x200000;
+
+				if (optmize_away && op->flags == 4) {
+					u32 data = _vmem_ReadMem32(op->rs1.imm_value());
+					op->op = shop_mov32;
+					op->rs1.type = FMT_IMM;
+					op->rs1._imm = data;
+				}
+			}
+		}
 
-			if (/*baddr==0xC158400 &&*/ blk->addr/PAGE_SIZE == op->rs1._imm/PAGE_SIZE)
+		if (0) {
+			//NOT WORKING
+			//WE NEED PROPER PAGELOCKS
+			if (op->op == shop_readm && op->rs1.is_imm() && op->rd.is_r32i() && op->rd._reg<16 && op->flags == 0x4 && op->rs3.is_null())
 			{
-				isi[op->rd._reg]=true;
-				rv[op->rd._reg]= ReadMem32(op->rs1._imm);
-				printf("IMM MOVE: %08X -> %08X\n",op->rs1._imm,rv[op->rd._reg]);
+				u32 baddr = blk->addr & 0x0FFFFFFF;
 
-				op->op=shop_mov32;
-				op->rs1._imm=rv[op->rd._reg];
+				if (/*baddr==0xC158400 &&*/ blk->addr / PAGE_SIZE == op->rs1._imm / PAGE_SIZE)
+				{
+					isi[op->rd._reg] = true;
+					rv[op->rd._reg] = ReadMem32(op->rs1._imm);
+					printf("IMM MOVE: %08X -> %08X\n", op->rs1._imm, rv[op->rd._reg]);
+
+					op->op = shop_mov32;
+					op->rs1._imm = rv[op->rd._reg];
+				}
 			}
 		}
 	}
@@ -925,7 +944,7 @@
 	*/
 	if (settings.dynarec.unstable_opt)
 		sq_pref(blk);
-	//constprop(blk); // crashes on ip
+	constprop(blk); // maybe it works w/o the readm parts?
 #if HOST_CPU==CPU_X86
 //	rdgrp(blk);
 //	wtgrp(blk);