Exclude sse and substract from HBD build.

BUG=aomedia:2397

Change-Id: Icf5333acb103d7811505ee87dc20d909ac99899d
diff --git a/aom_dsp/aom_dsp.cmake b/aom_dsp/aom_dsp.cmake
index 921535e..1f206b5 100644
--- a/aom_dsp/aom_dsp.cmake
+++ b/aom_dsp/aom_dsp.cmake
@@ -217,6 +217,7 @@
     list(REMOVE_ITEM AOM_DSP_ENCODER_INTRIN_SSE2
                      "${AOM_ROOT}/aom_dsp/x86/highbd_adaptive_quantize_sse2.c"
                      "${AOM_ROOT}/aom_dsp/x86/highbd_quantize_intrin_sse2.c"
+                     "${AOM_ROOT}/aom_dsp/x86/highbd_subtract_sse2.c"
                      "${AOM_ROOT}/aom_dsp/x86/highbd_variance_sse2.c")
   endif()
 
diff --git a/aom_dsp/aom_dsp_rtcd_defs.pl b/aom_dsp/aom_dsp_rtcd_defs.pl
index 0e9026c..b3fe0bf 100755
--- a/aom_dsp/aom_dsp_rtcd_defs.pl
+++ b/aom_dsp/aom_dsp_rtcd_defs.pl
@@ -584,14 +584,16 @@
   add_proto qw/void aom_subtract_block/, "int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride";
   specialize qw/aom_subtract_block neon msa sse2 avx2/;
 
-  add_proto qw/void aom_highbd_subtract_block/, "int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd";
-  specialize qw/aom_highbd_subtract_block sse2/;
-
   add_proto qw/int64_t/, "aom_sse", "const uint8_t *a, int a_stride, const uint8_t *b,int b_stride, int width, int height";
   specialize qw/aom_sse  sse4_1 avx2/;
 
-  add_proto qw/int64_t/, "aom_highbd_sse", "const uint8_t *a8, int a_stride, const uint8_t *b8,int b_stride, int width, int height";
-  specialize qw/aom_highbd_sse  sse4_1 avx2/;
+  if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
+    add_proto qw/void aom_highbd_subtract_block/, "int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride, int bd";
+    specialize qw/aom_highbd_subtract_block sse2/;
+
+    add_proto qw/int64_t/, "aom_highbd_sse", "const uint8_t *a8, int a_stride, const uint8_t *b8,int b_stride, int width, int height";
+    specialize qw/aom_highbd_sse  sse4_1 avx2/;
+  }
 
   if (aom_config("CONFIG_AV1_ENCODER") eq "yes") {
     #
@@ -602,10 +604,8 @@
 
     add_proto qw/uint64_t aom_sum_squares_i16/, "const int16_t *src, uint32_t N";
     specialize qw/aom_sum_squares_i16 sse2/;
-
   }
 
-
   #
   # Single block SAD / Single block Avg SAD
   #
diff --git a/aom_dsp/sse.c b/aom_dsp/sse.c
index 2493948..16f6b58 100644
--- a/aom_dsp/sse.c
+++ b/aom_dsp/sse.c
@@ -33,6 +33,7 @@
   return sse;
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 int64_t aom_highbd_sse_c(const uint8_t *a8, int a_stride, const uint8_t *b8,
                          int b_stride, int width, int height) {
   int y, x;
@@ -50,3 +51,4 @@
   }
   return sse;
 }
+#endif
diff --git a/aom_dsp/subtract.c b/aom_dsp/subtract.c
index 2f6da96..4f4e355 100644
--- a/aom_dsp/subtract.c
+++ b/aom_dsp/subtract.c
@@ -32,6 +32,7 @@
   }
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 void aom_highbd_subtract_block_c(int rows, int cols, int16_t *diff,
                                  ptrdiff_t diff_stride, const uint8_t *src8,
                                  ptrdiff_t src_stride, const uint8_t *pred8,
@@ -51,3 +52,4 @@
     src += src_stride;
   }
 }
+#endif
diff --git a/aom_dsp/x86/sse_avx2.c b/aom_dsp/x86/sse_avx2.c
index 42df981..b31388f4 100644
--- a/aom_dsp/x86/sse_avx2.c
+++ b/aom_dsp/x86/sse_avx2.c
@@ -211,6 +211,7 @@
   return sse;
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static INLINE void highbd_sse_w16_avx2(__m256i *sum, const uint16_t *a,
                                        const uint16_t *b) {
   const __m256i v_a_w = yy_loadu_256(a);
@@ -378,3 +379,4 @@
   }
   return sse;
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
diff --git a/aom_dsp/x86/sse_sse4.c b/aom_dsp/x86/sse_sse4.c
index 0d45003..7239570 100644
--- a/aom_dsp/x86/sse_sse4.c
+++ b/aom_dsp/x86/sse_sse4.c
@@ -175,6 +175,7 @@
   return sse;
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static INLINE void highbd_sse_w4x2_sse4_1(__m128i *sum, const uint16_t *a,
                                           int a_stride, const uint16_t *b,
                                           int b_stride) {
@@ -348,3 +349,4 @@
   }
   return sse;
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c
index 0c7bfc7..4018602 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -43,22 +43,26 @@
                            const uint8_t *src8, ptrdiff_t src_stride,
                            const uint8_t *pred8, ptrdiff_t pred_stride) {
   if (check_subtract_block_size(rows, cols)) {
+#if CONFIG_AV1_HIGHBITDEPTH
     if (is_cur_buf_hbd(xd)) {
       aom_highbd_subtract_block_c(rows, cols, diff, diff_stride, src8,
                                   src_stride, pred8, pred_stride, xd->bd);
       return;
     }
+#endif
+    (void)xd;
     aom_subtract_block_c(rows, cols, diff, diff_stride, src8, src_stride, pred8,
                          pred_stride);
 
     return;
   }
-
+#if CONFIG_AV1_HIGHBITDEPTH
   if (is_cur_buf_hbd(xd)) {
     aom_highbd_subtract_block(rows, cols, diff, diff_stride, src8, src_stride,
                               pred8, pred_stride, xd->bd);
     return;
   }
+#endif
   aom_subtract_block(rows, cols, diff, diff_stride, src8, src_stride, pred8,
                      pred_stride);
 }
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 4ed24f4..d2d509e 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1774,6 +1774,27 @@
   return total_sse;
 }
 
+static int64_t calculate_sse(MACROBLOCKD *const xd,
+                             const struct macroblock_plane *p,
+                             struct macroblockd_plane *pd, const int bw,
+                             const int bh) {
+  int64_t sse = 0;
+  const int shift = xd->bd - 8;
+#if CONFIG_AV1_HIGHBITDEPTH
+  if (is_cur_buf_hbd(xd)) {
+    sse = aom_highbd_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride,
+                         bw, bh);
+  } else {
+    sse =
+        aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw, bh);
+  }
+#else
+  sse = aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw, bh);
+#endif
+  sse = ROUND_POWER_OF_TWO(sse, shift * 2);
+  return sse;
+}
+
 static void model_rd_for_sb(const AV1_COMP *const cpi, BLOCK_SIZE bsize,
                             MACROBLOCK *x, MACROBLOCKD *xd, int plane_from,
                             int plane_to, int mi_row, int mi_col,
@@ -1809,14 +1830,7 @@
 
     if (x->skip_chroma_rd && plane) continue;
 
-    if (is_cur_buf_hbd(xd)) {
-      sse = aom_highbd_sse(p->src.buf, p->src.stride, pd->dst.buf,
-                           pd->dst.stride, bw, bh);
-    } else {
-      sse = aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw,
-                    bh);
-    }
-    sse = ROUND_POWER_OF_TWO(sse, (xd->bd - 8) * 2);
+    sse = calculate_sse(xd, p, pd, bw, bh);
 
     model_rd_from_sse(cpi, x, plane_bsize, plane, sse, bw * bh, &rate, &dist);
 
@@ -2517,17 +2531,8 @@
   const int dst_stride = pd->dst.stride;
   const uint8_t *const dst = pd->dst.buf;
   const int16_t *const src_diff = p->src_diff;
-  const int shift = (xd->bd - 8);
 
-  int64_t sse;
-  if (is_cur_buf_hbd(xd)) {
-    sse = aom_highbd_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride,
-                         bw, bh);
-  } else {
-    sse =
-        aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw, bh);
-  }
-  sse = ROUND_POWER_OF_TWO(sse, shift * 2);
+  int64_t sse = calculate_sse(xd, p, pd, bw, bh);
   const double sse_norm = (double)sse / num_samples;
 
   const unsigned int sad =
@@ -2731,18 +2736,10 @@
     if (x->skip_chroma_rd && plane) continue;
 
     const struct macroblock_plane *const p = &x->plane[plane];
-    const int shift = (xd->bd - 8);
     int bw, bh;
     get_txb_dimensions(xd, plane, plane_bsize, 0, 0, plane_bsize, NULL, NULL,
                        &bw, &bh);
-    if (is_cur_buf_hbd(xd)) {
-      sse = aom_highbd_sse(p->src.buf, p->src.stride, pd->dst.buf,
-                           pd->dst.stride, bw, bh);
-    } else {
-      sse = aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw,
-                    bh);
-    }
-    sse = ROUND_POWER_OF_TWO(sse, shift * 2);
+    sse = calculate_sse(xd, p, pd, bw, bh);
 
     model_rd_with_dnn(cpi, x, plane_bsize, plane, sse, bw * bh, &rate, &dist);
 
@@ -2836,17 +2833,9 @@
 
     int bw, bh;
     const struct macroblock_plane *const p = &x->plane[plane];
-    const int shift = (xd->bd - 8);
     get_txb_dimensions(xd, plane, plane_bsize, 0, 0, plane_bsize, NULL, NULL,
                        &bw, &bh);
-    if (is_cur_buf_hbd(xd)) {
-      sse = aom_highbd_sse(p->src.buf, p->src.stride, pd->dst.buf,
-                           pd->dst.stride, bw, bh);
-    } else {
-      sse = aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw,
-                    bh);
-    }
-    sse = ROUND_POWER_OF_TWO(sse, shift * 2);
+    sse = calculate_sse(xd, p, pd, bw, bh);
 
     model_rd_with_surffit(cpi, x, plane_bsize, plane, sse, bw * bh, &rate,
                           &dist);
@@ -2941,19 +2930,10 @@
 
     int bw, bh;
     const struct macroblock_plane *const p = &x->plane[plane];
-    const int shift = (xd->bd - 8);
     get_txb_dimensions(xd, plane, plane_bsize, 0, 0, plane_bsize, NULL, NULL,
                        &bw, &bh);
 
-    if (is_cur_buf_hbd(xd)) {
-      sse = aom_highbd_sse(p->src.buf, p->src.stride, pd->dst.buf,
-                           pd->dst.stride, bw, bh);
-    } else {
-      sse = aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw,
-                    bh);
-    }
-
-    sse = ROUND_POWER_OF_TWO(sse, shift * 2);
+    sse = calculate_sse(xd, p, pd, bw, bh);
     model_rd_with_curvfit(cpi, x, plane_bsize, plane, sse, bw * bh, &rate,
                           &dist);
 
@@ -5932,14 +5912,7 @@
 
     if (x->skip_chroma_rd && plane) continue;
 
-    if (is_cur_buf_hbd(xd)) {
-      sse = aom_highbd_sse(p->src.buf, p->src.stride, pd->dst.buf,
-                           pd->dst.stride, bw, bh);
-    } else {
-      sse = aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw,
-                    bh);
-    }
-    sse = ROUND_POWER_OF_TWO(sse, (xd->bd - 8) * 2);
+    sse = calculate_sse(xd, p, pd, bw, bh);
 
     RD_STATS rd_stats;
     if (plane == 0) {
@@ -7510,12 +7483,17 @@
   const int bd_round = hbd ? (xd->bd - 8) * 2 : 0;
 
   DECLARE_ALIGNED(32, int16_t, residual0[MAX_SB_SQUARE]);  // src - pred0
+#if CONFIG_AV1_HIGHBITDEPTH
   if (hbd) {
     aom_highbd_subtract_block(bh, bw, residual0, bw, src->buf, src->stride,
                               CONVERT_TO_BYTEPTR(p0), bw, xd->bd);
   } else {
     aom_subtract_block(bh, bw, residual0, bw, src->buf, src->stride, p0, bw);
   }
+#else
+  (void)hbd;
+  aom_subtract_block(bh, bw, residual0, bw, src->buf, src->stride, p0, bw);
+#endif
 
   int64_t sign_limit = ((int64_t)aom_sum_squares_i16(residual0, N) -
                         (int64_t)aom_sum_squares_i16(residual1, N)) *
@@ -7694,6 +7672,7 @@
   const int bh = block_size_high[bsize];
   DECLARE_ALIGNED(32, int16_t, residual1[MAX_SB_SQUARE]);  // src - pred1
   DECLARE_ALIGNED(32, int16_t, diff10[MAX_SB_SQUARE]);     // pred1 - pred0
+#if CONFIG_AV1_HIGHBITDEPTH
   if (is_cur_buf_hbd(xd)) {
     aom_highbd_subtract_block(bh, bw, residual1, bw, src->buf, src->stride,
                               CONVERT_TO_BYTEPTR(p1), bw, xd->bd);
@@ -7703,6 +7682,10 @@
     aom_subtract_block(bh, bw, residual1, bw, src->buf, src->stride, p1, bw);
     aom_subtract_block(bh, bw, diff10, bw, p1, bw, p0, bw);
   }
+#else
+  aom_subtract_block(bh, bw, residual1, bw, src->buf, src->stride, p1, bw);
+  aom_subtract_block(bh, bw, diff10, bw, p1, bw, p0, bw);
+#endif
   int8_t wedge_index = -1;
   int64_t rd =
       pick_wedge_fixed_sign(cpi, x, bsize, residual1, diff10, 0, &wedge_index);
@@ -7756,6 +7739,7 @@
   av1_build_inter_predictors_for_planes_single_buf(
       xd, bsize, 0, 0, mi_row, mi_col, 1, preds1, strides, can_use_previous);
   const struct buf_2d *const src = &x->plane[0].src;
+#if CONFIG_AV1_HIGHBITDEPTH
   if (is_cur_buf_hbd(xd)) {
     aom_highbd_subtract_block(bh, bw, residual1, bw, src->buf, src->stride,
                               CONVERT_TO_BYTEPTR(*preds1), bw, xd->bd);
@@ -7766,6 +7750,10 @@
                        bw);
     aom_subtract_block(bh, bw, diff10, bw, *preds1, bw, *preds0, bw);
   }
+#else
+  aom_subtract_block(bh, bw, residual1, bw, src->buf, src->stride, *preds1, bw);
+  aom_subtract_block(bh, bw, diff10, bw, *preds1, bw, *preds0, bw);
+#endif
 }
 
 // Takes a backup of rate, distortion and model_rd for future reuse
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index 34eb189..affce91 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -189,6 +189,7 @@
         0, 0, FILTER_INTRA_MODES, src, src_stride, dst, dst_stride, 0, 0, 0);
 
     if (use_satd) {
+#if CONFIG_AV1_HIGHBITDEPTH
       if (is_cur_buf_hbd(xd)) {
         aom_highbd_subtract_block(bh, bw, src_diff, bw, src, src_stride, dst,
                                   dst_stride, xd->bd);
@@ -196,10 +197,15 @@
         aom_subtract_block(bh, bw, src_diff, bw, src, src_stride, dst,
                            dst_stride);
       }
+#else
+      aom_subtract_block(bh, bw, src_diff, bw, src, src_stride, dst,
+                         dst_stride);
+#endif
       wht_fwd_txfm(src_diff, bw, coeff, tx_size, is_cur_buf_hbd(xd));
       intra_cost = aom_satd(coeff, pix_num);
     } else {
       int64_t intra_sse;
+#if CONFIG_AV1_HIGHBITDEPTH
       if (is_cur_buf_hbd(xd)) {
         intra_sse =
             aom_highbd_sse(xd->cur_buf->y_buffer + mb_y_offset,
@@ -208,6 +214,10 @@
         intra_sse = aom_sse(xd->cur_buf->y_buffer + mb_y_offset,
                             xd->cur_buf->y_stride, predictor, bw, bw, bh);
       }
+#else
+      intra_sse = aom_sse(xd->cur_buf->y_buffer + mb_y_offset,
+                          xd->cur_buf->y_stride, predictor, bw, bw, bh);
+#endif
       intra_cost = ROUND_POWER_OF_TWO(intra_sse, (xd->bd - 8) * 2);
     }
     intra_cost += qstep_cur_noise;
@@ -261,6 +271,7 @@
                               mi_row * MI_SIZE, 0, 0, MV_PRECISION_Q3,
                               mi_col * MI_SIZE, mi_row * MI_SIZE, xd, 0);
     if (use_satd) {
+#if CONFIG_AV1_HIGHBITDEPTH
       if (is_cur_buf_hbd(xd)) {
         aom_highbd_subtract_block(bh, bw, src_diff, bw,
                                   xd->cur_buf->y_buffer + mb_y_offset,
@@ -270,11 +281,17 @@
                            xd->cur_buf->y_buffer + mb_y_offset,
                            xd->cur_buf->y_stride, predictor, bw);
       }
+#else
+      aom_subtract_block(bh, bw, src_diff, bw,
+                         xd->cur_buf->y_buffer + mb_y_offset,
+                         xd->cur_buf->y_stride, predictor, bw);
+#endif
       wht_fwd_txfm(src_diff, bw, coeff, tx_size, is_cur_buf_hbd(xd));
 
       inter_cost = aom_satd(coeff, pix_num);
     } else {
       int64_t inter_sse;
+#if CONFIG_AV1_HIGHBITDEPTH
       if (is_cur_buf_hbd(xd)) {
         inter_sse =
             aom_highbd_sse(xd->cur_buf->y_buffer + mb_y_offset,
@@ -283,6 +300,10 @@
         inter_sse = aom_sse(xd->cur_buf->y_buffer + mb_y_offset,
                             xd->cur_buf->y_stride, predictor, bw, bw, bh);
       }
+#else
+      inter_sse = aom_sse(xd->cur_buf->y_buffer + mb_y_offset,
+                          xd->cur_buf->y_stride, predictor, bw, bw, bh);
+#endif
       inter_cost = ROUND_POWER_OF_TWO(inter_sse, (xd->bd - 8) * 2);
     }
     inter_cost_weighted = inter_cost + qstep_ref_noise;
@@ -846,6 +867,7 @@
                                 dst_buf, dst_stride, 0, 0, 0);
 
         if (use_satd) {
+#if CONFIG_AV1_HIGHBITDEPTH
           if (is_cur_buf_hbd(xd)) {
             aom_highbd_subtract_block(bh, bw, src_diff, bw, src_buf, src_stride,
                                       dst_buf, dst_stride, xd->bd);
@@ -853,17 +875,25 @@
             aom_subtract_block(bh, bw, src_diff, bw, src_buf, src_stride,
                                dst_buf, dst_stride);
           }
+#else
+          aom_subtract_block(bh, bw, src_diff, bw, src_buf, src_stride, dst_buf,
+                             dst_stride);
+#endif
           wht_fwd_txfm(src_diff, bw, coeff, tx_size, is_cur_buf_hbd(xd));
 
           intra_cost = aom_satd(coeff, pix_num);
         } else {
           int64_t sse;
+#if CONFIG_AV1_HIGHBITDEPTH
           if (is_cur_buf_hbd(xd)) {
             sse = aom_highbd_sse(src_buf, src_stride, dst_buf, dst_stride, bw,
                                  bh);
           } else {
             sse = aom_sse(src_buf, src_stride, dst_buf, dst_stride, bw, bh);
           }
+#else
+          sse = aom_sse(src_buf, src_stride, dst_buf, dst_stride, bw, bh);
+#endif
           intra_cost = ROUND_POWER_OF_TWO(sse, (xd->bd - 8) * 2);
         }
         if (intra_cost < best_intra_cost) best_intra_cost = intra_cost;
@@ -887,6 +917,7 @@
           mi_col * MI_SIZE, mi_row * MI_SIZE, 0, 0, MV_PRECISION_Q3,
           mi_col * MI_SIZE, mi_row * MI_SIZE, xd, 0);
       if (use_satd) {
+#if CONFIG_AV1_HIGHBITDEPTH
         if (is_cur_buf_hbd(xd)) {
           aom_highbd_subtract_block(bh, bw, src_diff, bw,
                                     src->y_buffer + mb_y_offset, src->y_stride,
@@ -895,10 +926,15 @@
           aom_subtract_block(bh, bw, src_diff, bw, src->y_buffer + mb_y_offset,
                              src->y_stride, predictor, bw);
         }
+#else
+        aom_subtract_block(bh, bw, src_diff, bw, src->y_buffer + mb_y_offset,
+                           src->y_stride, predictor, bw);
+#endif
         wht_fwd_txfm(src_diff, bw, coeff, tx_size, is_cur_buf_hbd(xd));
         inter_cost = aom_satd(coeff, pix_num);
       } else {
         int64_t sse;
+#if CONFIG_AV1_HIGHBITDEPTH
         if (is_cur_buf_hbd(xd)) {
           sse = aom_highbd_sse(src->y_buffer + mb_y_offset, src->y_stride,
                                predictor, bw, bw, bh);
@@ -906,6 +942,10 @@
           sse = aom_sse(src->y_buffer + mb_y_offset, src->y_stride, predictor,
                         bw, bw, bh);
         }
+#else
+        sse = aom_sse(src->y_buffer + mb_y_offset, src->y_stride, predictor, bw,
+                      bw, bh);
+#endif
         inter_cost = ROUND_POWER_OF_TWO(sse, (xd->bd - 8) * 2);
       }
 
diff --git a/test/subtract_test.cc b/test/subtract_test.cc
index 7dcedf5..e009771 100644
--- a/test/subtract_test.cc
+++ b/test/subtract_test.cc
@@ -104,6 +104,7 @@
                         ::testing::Values(aom_subtract_block_msa));
 #endif
 
+#if CONFIG_AV1_HIGHBITDEPTH
 typedef void (*HBDSubtractFunc)(int rows, int cols, int16_t *diff_ptr,
                                 ptrdiff_t diff_stride, const uint8_t *src_ptr,
                                 ptrdiff_t src_stride, const uint8_t *pred_ptr,
@@ -207,7 +208,6 @@
 TEST_P(AV1HBDSubtractBlockTest, DISABLED_Speed) { RunForSpeed(); }
 
 #if HAVE_SSE2
-
 const Params kAV1HBDSubtractBlock_sse2[] = {
   make_tuple(4, 4, 12, &aom_highbd_subtract_block_sse2),
   make_tuple(4, 4, 12, &aom_highbd_subtract_block_c),
@@ -246,4 +246,5 @@
 INSTANTIATE_TEST_CASE_P(SSE2, AV1HBDSubtractBlockTest,
                         ::testing::ValuesIn(kAV1HBDSubtractBlock_sse2));
 #endif  // HAVE_SSE2
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 }  // namespace
diff --git a/test/sum_squares_test.cc b/test/sum_squares_test.cc
index f26a646..b41c1ca 100644
--- a/test/sum_squares_test.cc
+++ b/test/sum_squares_test.cc
@@ -242,7 +242,12 @@
   virtual void SetUp() {
     params_ = GET_PARAM(0);
     width_ = GET_PARAM(1);
-    isHbd_ = params_.ref_func == aom_highbd_sse_c;
+    isHbd_ =
+#if CONFIG_AV1_HIGHBITDEPTH
+        params_.ref_func == aom_highbd_sse_c;
+#else
+        0;
+#endif
     rnd_.Reset(ACMRandom::DeterministicSeed());
     src_ = reinterpret_cast<uint8_t *>(aom_memalign(32, 256 * 256 * 2));
     ref_ = reinterpret_cast<uint8_t *>(aom_memalign(32, 256 * 256 * 2));
@@ -380,18 +385,24 @@
   }
 }
 #if HAVE_SSE4_1
-TestSSEFuncs sse_sse4[] = { TestSSEFuncs(&aom_sse_c, &aom_sse_sse4_1),
-                            TestSSEFuncs(&aom_highbd_sse_c,
-                                         &aom_highbd_sse_sse4_1) };
+TestSSEFuncs sse_sse4[] = {
+  TestSSEFuncs(&aom_sse_c, &aom_sse_sse4_1),
+#if CONFIG_AV1_HIGHBITDEPTH
+  TestSSEFuncs(&aom_highbd_sse_c, &aom_highbd_sse_sse4_1)
+#endif
+};
 INSTANTIATE_TEST_CASE_P(SSE4_1, SSETest,
                         Combine(ValuesIn(sse_sse4), Range(4, 129, 4)));
 #endif  // HAVE_SSE4_1
 
 #if HAVE_AVX2
 
-TestSSEFuncs sse_avx2[] = { TestSSEFuncs(&aom_sse_c, &aom_sse_avx2),
-                            TestSSEFuncs(&aom_highbd_sse_c,
-                                         &aom_highbd_sse_avx2) };
+TestSSEFuncs sse_avx2[] = {
+  TestSSEFuncs(&aom_sse_c, &aom_sse_avx2),
+#if CONFIG_AV1_HIGHBITDEPTH
+  TestSSEFuncs(&aom_highbd_sse_c, &aom_highbd_sse_avx2)
+#endif
+};
 INSTANTIATE_TEST_CASE_P(AVX2, SSETest,
                         Combine(ValuesIn(sse_avx2), Range(4, 129, 4)));
 #endif  // HAVE_AVX2