Skip to content

Commit

Permalink
Apparently Open Watcom's optimizer is not smart enough to consider
Browse files Browse the repository at this point in the history
baking 'static const' integer values into the immediate forms of x86
instructions. I guess I'm too used to the GCC optimizer. Convert
resampler constants to #define instead to make it use them as immediate.
  • Loading branch information
joncampbell123 committed Oct 11, 2017
1 parent 4067d90 commit 02ebf3e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions media/dosamp/dosamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,16 +497,22 @@ static unsigned char wav_play_empty = 0;/* if set, buffer is
static unsigned char wav_playing = 0;
static unsigned char wav_prepared = 0;

/* NTS: Unlike GCC, Open Watcom doesn't cue into the declaration as "static const" that
* it can optimize the code by baking the static const into the immediate form of
* x86 instructions. Therefore optimization of that form requires the use of
* #define macros instead. Making Open Watcom allocate memory for the constants
* and then use the memory locations for what could be optimized slows this code
* down. */
#if TARGET_MSDOS == 32
# define resample_100_shift (32)
# define resample_100 (1ULL << 32ULL)
typedef signed long long resample_intermediate_t;
static const unsigned char resample_100_shift = 32;
static const unsigned long long resample_100 = 1ULL << 32ULL;
static unsigned long long resample_step = 0; /* 16.16 resampling step */
static unsigned long long resample_frac = 0;
#else
# define resample_100_shift (16)
# define resample_100 (1UL << 16UL)
typedef signed long resample_intermediate_t;
static const unsigned char resample_100_shift = 16;
static const unsigned long resample_100 = 1UL << 16UL;
static unsigned long resample_step = 0; /* 16.16 resampling step */
static unsigned long resample_frac = 0;
#endif
Expand Down

0 comments on commit 02ebf3e

Please sign in to comment.