From ccef3646dbf2fbb2951828006765ec286c6c9eec Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 3 Jun 2022 16:03:48 +0100 Subject: [PATCH] VarAction2: Set value inferences for operations with eq/neq adjust types --- src/newgrf.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 5676fdc0d5..028200ddee 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5824,12 +5824,14 @@ static void OptimiseVarAction2Adjust(VarAction2OptimiseState &state, const GrfSp } }); handle_group(adjust.subroutine); - } else { + } else if (adjust.operation == DSGA_OP_RST) { + state.inference = VA2AIF_SINGLE_LOAD; + } + if (adjust.type == DSGA_TYPE_EQ || adjust.type == DSGA_TYPE_NEQ) { if (adjust.operation == DSGA_OP_RST) { - state.inference = VA2AIF_SINGLE_LOAD; - if (adjust.type == DSGA_TYPE_EQ || adjust.type == DSGA_TYPE_NEQ) { - state.inference |= VA2AIF_SIGNED_NON_NEGATIVE | VA2AIF_ONE_OR_ZERO; - } + state.inference |= VA2AIF_SIGNED_NON_NEGATIVE | VA2AIF_ONE_OR_ZERO; + } else if (adjust.operation == DSGA_OP_OR || adjust.operation == DSGA_OP_XOR || adjust.operation == DSGA_OP_AND) { + state.inference |= (prev_inference & (VA2AIF_SIGNED_NON_NEGATIVE | VA2AIF_ONE_OR_ZERO)); } } } else {