Bug #3100

High (pseudo-) sprite usage for conditional expressions

Added by michi_cc about 8 years ago. Updated about 8 years ago.

Status:NewStart date:2011-09-30
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

CETS has a line similar to the following in each vehicle's item definition:

climates_available: (avail_DRG_2_ext || avail_DR_3_ext || avail_DB_3_ext) ? ALL_CLIMATES : NO_CLIMATE;

The avail_... params are calculated by NML from user params.

The above code line results in the following Act9/ActD pseudo-code:

p[99] = 0;

p[102] = 0;
if (p[81] != 0) p[102] = 1;

p[103] = 0;
if (p[77] != 0) p[103] = 1;

p[101] = p[102] | p[103];

p[102] = 0;
if (p[71] != 0) p[102] = 1;

p[100] = p[101] | p[102];

if (p[100] != 0) p[99] = 0xF;

-> contents of p[99] used by Act6

The code could be simplified to the one below, saving 9 pseudo sprites:

p[99] = 0;

p[100] = p[81] | p[77];
p[100] = p[100] | p[71];

if (p[100] != 0) p[99] = 0xF;

-> contents of p[99] used by Act6

History

#1 Updated by michi_cc about 8 years ago

To reproduce: Look at the GRF/NFO output for the DRG_VT07 in CETS.

#2 Updated by yexo about 8 years ago

r1672 and r1673 improved this specific test-case. Leaving this task open as in general we should take a look at common subexpression elimination.

Also available in: Atom PDF