From e22c8881e7e0fc683e3fddb8aa9844f4a4c7e8ff Mon Sep 17 00:00:00 2001 From: George Koehler Date: Fri, 30 Sep 2016 11:50:50 -0400 Subject: [PATCH] Add a rule for sdl ldl $1==$2 to work around a bug. In our powerpc table, sdl fails to kill the old value of the local. This is a bug, because a later ldl can load the old value instead of the newly stored value. By rewriting "sdl 0" "ldl 0" as "dup 8" "sdl 0", the newly added rule works around the bug, but only when the ldl is immediately after the sdl. This rule improves code that uses double-precision floating point. The output of printf("%f", 6.0) in C changes from all zero digits to "6000000" but still doesn't print the decimal point. The result of atof("-123.456") becomes correct. In startrek, I can now move the Enterprise, but I still can't fire phasers without crashing the game. We already have a rule for stl lol $1==$2. We had two copies of the rule, so I am deleting the second copy. --- mach/powerpc/ncg/table | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mach/powerpc/ncg/table b/mach/powerpc/ncg/table index 93b7722ee..1cb51c2d5 100644 --- a/mach/powerpc/ncg/table +++ b/mach/powerpc/ncg/table @@ -923,10 +923,14 @@ PATTERNS pat dup $1==INT32 /* Duplicate word on top of stack */ with GPR yields %1 %1 + with FSREG + yields %1 %1 pat dup $1==INT64 /* Duplicate double-word on top of stack */ with GPR GPR yields %2 %1 %2 %1 + with FREG + yields %1 %1 pat exg $1==INT32 /* Exchange top two words on stack */ with GPR GPR @@ -936,7 +940,12 @@ PATTERNS leaving dup 4 stl $1 - + + pat sdl ldl $1==$2 /* Store then load double local */ + leaving + dup 8 + sdl $1 + pat lal sti lal loi $1==$3 && $2==$4 /* Store then load local, of a different size */ leaving dup INT32 @@ -1045,12 +1054,7 @@ PATTERNS leaving lol $1 sti INT32 - - pat stl lol $1==$2 /* Save then load (generated by C compiler) */ - leaving - dup 4 - stl $1 - + pat zrl /* Zero local */ leaving loc 0 -- 2.34.1