From 8d208ac3aa65d3d5d8f04ef6981336daed6d3575 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 19 Nov 2001 17:51:31 +0000 Subject: [PATCH] make float != 0 tests work on alpha for when the value is actually an integer (works fine on intel, but on alpha the denormals either produce an exception or true zero: not quite desirable:) --- libs/gamecode/engine/pr_exec.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libs/gamecode/engine/pr_exec.c b/libs/gamecode/engine/pr_exec.c index ff3638b59..564754cd3 100644 --- a/libs/gamecode/engine/pr_exec.c +++ b/libs/gamecode/engine/pr_exec.c @@ -248,6 +248,12 @@ PR_LeaveFunction (progs_t * pr) #define OPB (pr->pr_globals[st->b]) #define OPC (pr->pr_globals[st->c]) +/* + This gets around the problem of needing to test for -0.0 but denormals + causing exceptions (or wrong results for what we need) on the alpha. +*/ +#define FNZ(x) ((x).integer_var && (x).integer_var != 0x80000000) + /* PR_ExecuteProgram @@ -369,13 +375,13 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum) OPC.float_var = OPA.float_var < OPB.float_var; break; case OP_AND: // OPA and OPB have to be float for -0.0 - OPC.integer_var = OPA.float_var && OPB.float_var; + OPC.integer_var = FNZ (OPA) && FNZ (OPB); break; case OP_OR: // OPA and OPB have to be float for -0.0 - OPC.integer_var = OPA.float_var || OPB.float_var; + OPC.integer_var = FNZ (OPA) || FNZ (OPB); break; case OP_NOT_F: - OPC.integer_var = !OPA.float_var; + OPC.integer_var = !FNZ (OPA); break; case OP_NOT_V: OPC.integer_var = VectorIsZero (OPA.vector_var);