Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2016-08-06 07:06:48 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-08-06 07:06:48 +0300
commit09b53529280fd132438d24d39dd0f1614318abfd (patch)
tree92c661ba007d6f647ddcfa8fba096790b59b2f27
parent416611cfa127df360d6902794b36e426477061a0 (diff)
Getting gcc to use cmovs rather than branches in alg_quant()
Speeds up CELT encoding by around 5% on x86
-rw-r--r--celt/vq.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/celt/vq.c b/celt/vq.c
index 12437167..4bc6b36f 100644
--- a/celt/vq.c
+++ b/celt/vq.c
@@ -185,12 +185,10 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc,
/* Get rid of the sign */
sum = 0;
j=0; do {
- if (X[j]>0)
- signx[j]=1;
- else {
- signx[j]=-1;
- X[j]=-X[j];
- }
+ /* OPT: Make sure the following two lines result in conditional moves
+ rather than branches. */
+ signx[j] = X[j]>0 ? 1 : -1;
+ X[j] = ABS16(X[j]);
iy[j] = 0;
y[j] = 0;
} while (++j<N);
@@ -306,8 +304,9 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc,
j=0;
do {
X[j] = MULT16_16(signx[j],X[j]);
- if (signx[j] < 0)
- iy[j] = -iy[j];
+ /* OPT: Make sure your compiler uses a conditional move here rather than
+ a branch. */
+ iy[j] = signx[j] < 0 ? -iy[j] : iy[j];
} while (++j<N);
encode_pulses(iy, N, K, enc);