Exclude hbd functions in av1_rtcd_defs.pl from HBD flag.

~1% binary size reduction.

BUG=aomedia:2397

Change-Id: I751a901f902faa907224a962fee3e794ef69113f
diff --git a/av1/av1.cmake b/av1/av1.cmake
index 647d0b0..56c169bf 100644
--- a/av1/av1.cmake
+++ b/av1/av1.cmake
@@ -272,7 +272,8 @@
 
 if(NOT CONFIG_AV1_HIGHBITDEPTH)
   list(REMOVE_ITEM AOM_AV1_COMMON_INTRIN_SSE4_1
-                   "${AOM_ROOT}/av1/common/x86/highbd_convolve_2d_sse4.c")
+                   "${AOM_ROOT}/av1/common/x86/highbd_convolve_2d_sse4.c"
+                   "${AOM_ROOT}/av1/common/x86/highbd_warp_plane_sse4.c")
 endif()
 
 list(APPEND AOM_AV1_COMMON_INTRIN_AVX2
@@ -308,6 +309,12 @@
             "${AOM_ROOT}/av1/encoder/x86/highbd_block_error_intrin_sse2.c"
             "${AOM_ROOT}/av1/encoder/x86/wedge_utils_sse2.c")
 
+if(NOT CONFIG_AV1_HIGHBITDEPTH)
+  list(
+    REMOVE_ITEM AOM_AV1_ENCODER_INTRIN_SSE2
+                "${AOM_ROOT}/av1/encoder/x86/highbd_block_error_intrin_sse2.c")
+endif()
+
 list(APPEND AOM_AV1_ENCODER_INTRIN_SSE3 "${AOM_ROOT}/av1/encoder/x86/ml_sse3.c")
 
 list(APPEND AOM_AV1_ENCODER_ASM_SSSE3_X86_64
@@ -340,6 +347,12 @@
             "${AOM_ROOT}/av1/encoder/x86/rdopt_avx2.c"
             "${AOM_ROOT}/av1/encoder/x86/pickrst_avx2.c")
 
+if(NOT CONFIG_AV1_HIGHBITDEPTH)
+  list(
+    REMOVE_ITEM AOM_AV1_ENCODER_INTRIN_AVX2
+                "${AOM_ROOT}/av1/encoder/x86/highbd_block_error_intrin_avx2.c")
+endif()
+
 list(APPEND AOM_AV1_ENCODER_INTRIN_NEON
             "${AOM_ROOT}/av1/encoder/arm/neon/quantize_neon.c"
             "${AOM_ROOT}/av1/encoder/arm/neon/av1_error_neon.c")
diff --git a/av1/common/arm/cfl_neon.c b/av1/common/arm/cfl_neon.c
index 39025b5..371be5f 100644
--- a/av1/common/arm/cfl_neon.c
+++ b/av1/common/arm/cfl_neon.c
@@ -131,6 +131,7 @@
   } while ((pred_buf_q3 += CFL_BUF_LINE) < end);
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 #ifndef __aarch64__
 uint16x8_t vpaddq_u16(uint16x8_t a, uint16x8_t b) {
   return vcombine_u16(vpadd_u16(vget_low_u16(a), vget_high_u16(a)),
@@ -247,6 +248,7 @@
     input += input_stride;
   } while ((pred_buf_q3 += CFL_BUF_LINE) < end);
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 CFL_GET_SUBSAMPLE_FUNCTION(neon)
 
@@ -511,6 +513,7 @@
 
 CFL_PREDICT_FN(neon, lbd)
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static INLINE uint16x4_t clamp_s16(int16x4_t a, int16x4_t max) {
   return vreinterpret_u16_s16(vmax_s16(vmin_s16(a, max), vdup_n_s16(0)));
 }
@@ -582,3 +585,4 @@
 }
 
 CFL_PREDICT_FN(neon, hbd)
+#endif  // CONFIG_AV1_HIGHBITDEPTH
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl
index 15bb5cc..792f171 100644
--- a/av1/common/av1_rtcd_defs.pl
+++ b/av1/common/av1_rtcd_defs.pl
@@ -60,16 +60,19 @@
 typedef void (*cfl_subsample_lbd_fn)(const uint8_t *input, int input_stride,
                                      uint16_t *output_q3);
 
+#if CONFIG_AV1_HIGHBITDEPTH
 typedef void (*cfl_subsample_hbd_fn)(const uint16_t *input, int input_stride,
                                      uint16_t *output_q3);
 
+typedef void (*cfl_predict_hbd_fn)(const int16_t *src, uint16_t *dst,
+                                   int dst_stride, int alpha_q3, int bd);
+#endif
+
 typedef void (*cfl_subtract_average_fn)(const uint16_t *src, int16_t *dst);
 
 typedef void (*cfl_predict_lbd_fn)(const int16_t *src, uint8_t *dst,
                                    int dst_stride, int alpha_q3);
 
-typedef void (*cfl_predict_hbd_fn)(const int16_t *src, uint16_t *dst,
-                                   int dst_stride, int alpha_q3, int bd);
 EOF
 }
 forward_decls qw/av1_common_forward_decls/;
@@ -283,9 +286,10 @@
   add_proto qw/void av1_quantize_b/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, const qm_val_t * qm_ptr, const qm_val_t * iqm_ptr, int log_scale";
 
   # ENCODEMB INVOKE
-
-  add_proto qw/int64_t av1_highbd_block_error/, "const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd";
-  specialize qw/av1_highbd_block_error sse2 avx2/;
+  if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
+    add_proto qw/int64_t av1_highbd_block_error/, "const tran_low_t *coeff, const tran_low_t *dqcoeff, intptr_t block_size, int64_t *ssz, int bd";
+    specialize qw/av1_highbd_block_error sse2 avx2/;
+  }
 
   if (aom_config("CONFIG_REALTIME_ONLY") ne "yes") {
     add_proto qw/void av1_highbd_apply_temporal_filter/, "const uint8_t *yf, int y_stride, const uint8_t *yp, int y_buf_stride, const uint8_t *uf, const uint8_t *vf, int uv_stride, const uint8_t *up, const uint8_t *vp, int uv_buf_stride, unsigned int block_width, unsigned int block_height, int ss_x, int ss_y, int strength, const int *blk_fw, int use_32x32, uint32_t *y_accumulator, uint16_t *y_count, uint32_t *u_accumulator, uint16_t *u_count, uint32_t *v_accumulator, uint16_t *v_count";
@@ -321,15 +325,17 @@
   add_proto qw/void av1_compute_stats/,  "int wiener_win, const uint8_t *dgd8, const uint8_t *src8, int h_start, int h_end, int v_start, int v_end, int dgd_stride, int src_stride, int64_t *M, int64_t *H";
   specialize qw/av1_compute_stats sse4_1 avx2/;
 
-  add_proto qw/void av1_compute_stats_highbd/,  "int wiener_win, const uint8_t *dgd8, const uint8_t *src8, int h_start, int h_end, int v_start, int v_end, int dgd_stride, int src_stride, int64_t *M, int64_t *H, aom_bit_depth_t bit_depth";
-  specialize qw/av1_compute_stats_highbd sse4_1 avx2/;
-
+  if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
+    add_proto qw/void av1_compute_stats_highbd/,  "int wiener_win, const uint8_t *dgd8, const uint8_t *src8, int h_start, int h_end, int v_start, int v_end, int dgd_stride, int src_stride, int64_t *M, int64_t *H, aom_bit_depth_t bit_depth";
+    specialize qw/av1_compute_stats_highbd sse4_1 avx2/;
+  }
   add_proto qw/int64_t av1_lowbd_pixel_proj_error/, " const uint8_t *src8, int width, int height, int src_stride, const uint8_t *dat8, int dat_stride, int32_t *flt0, int flt0_stride, int32_t *flt1, int flt1_stride, int xq[2], const sgr_params_type *params";
   specialize qw/av1_lowbd_pixel_proj_error sse4_1 avx2/;
 
-  add_proto qw/int64_t av1_highbd_pixel_proj_error/, " const uint8_t *src8, int width, int height, int src_stride, const uint8_t *dat8, int dat_stride, int32_t *flt0, int flt0_stride, int32_t *flt1, int flt1_stride, int xq[2], const sgr_params_type *params";
-  specialize qw/av1_highbd_pixel_proj_error sse4_1 avx2/;
-
+  if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
+    add_proto qw/int64_t av1_highbd_pixel_proj_error/, " const uint8_t *src8, int width, int height, int src_stride, const uint8_t *dat8, int dat_stride, int32_t *flt0, int flt0_stride, int32_t *flt1, int flt1_stride, int xq[2], const sgr_params_type *params";
+    specialize qw/av1_highbd_pixel_proj_error sse4_1 avx2/;
+  }
   add_proto qw/void av1_get_horver_correlation_full/, " const int16_t *diff, int stride, int w, int h, float *hcorr, float *vcorr";
   specialize qw/av1_get_horver_correlation_full sse4_1 avx2/;
 
@@ -370,8 +376,10 @@
 add_proto qw/void av1_warp_affine/, "const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
 specialize qw/av1_warp_affine sse4_1 avx2 neon/;
 
-add_proto qw/void av1_highbd_warp_affine/, "const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
-specialize qw/av1_highbd_warp_affine sse4_1/;
+if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
+  add_proto qw/void av1_highbd_warp_affine/, "const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
+  specialize qw/av1_highbd_warp_affine sse4_1/;
+}
 
 add_proto qw/int64_t av1_calc_frame_error/, "const uint8_t *const ref, int stride, const uint8_t *const dst, int p_width, int p_height, int p_stride";
 specialize qw/av1_calc_frame_error sse2 avx2/;
@@ -460,19 +468,21 @@
 add_proto qw/cfl_subsample_lbd_fn cfl_get_luma_subsampling_444_lbd/, "TX_SIZE tx_size";
 specialize qw/cfl_get_luma_subsampling_444_lbd ssse3 avx2 neon/;
 
-add_proto qw/cfl_subsample_hbd_fn cfl_get_luma_subsampling_420_hbd/, "TX_SIZE tx_size";
-specialize qw/cfl_get_luma_subsampling_420_hbd ssse3 avx2 neon/;
+if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
+  add_proto qw/cfl_subsample_hbd_fn cfl_get_luma_subsampling_420_hbd/, "TX_SIZE tx_size";
+  specialize qw/cfl_get_luma_subsampling_420_hbd ssse3 avx2 neon/;
 
-add_proto qw/cfl_subsample_hbd_fn cfl_get_luma_subsampling_422_hbd/, "TX_SIZE tx_size";
-specialize qw/cfl_get_luma_subsampling_422_hbd ssse3 avx2 neon/;
+  add_proto qw/cfl_subsample_hbd_fn cfl_get_luma_subsampling_422_hbd/, "TX_SIZE tx_size";
+  specialize qw/cfl_get_luma_subsampling_422_hbd ssse3 avx2 neon/;
 
-add_proto qw/cfl_subsample_hbd_fn cfl_get_luma_subsampling_444_hbd/, "TX_SIZE tx_size";
-specialize qw/cfl_get_luma_subsampling_444_hbd ssse3 avx2 neon/;
+  add_proto qw/cfl_subsample_hbd_fn cfl_get_luma_subsampling_444_hbd/, "TX_SIZE tx_size";
+  specialize qw/cfl_get_luma_subsampling_444_hbd ssse3 avx2 neon/;
+
+  add_proto qw/cfl_predict_hbd_fn cfl_get_predict_hbd_fn/, "TX_SIZE tx_size";
+  specialize qw/cfl_get_predict_hbd_fn ssse3 avx2 neon/;
+}
 
 add_proto qw/cfl_predict_lbd_fn cfl_get_predict_lbd_fn/, "TX_SIZE tx_size";
 specialize qw/cfl_get_predict_lbd_fn ssse3 avx2 neon/;
 
-add_proto qw/cfl_predict_hbd_fn cfl_get_predict_hbd_fn/, "TX_SIZE tx_size";
-specialize qw/cfl_get_predict_hbd_fn ssse3 avx2 neon/;
-
 1;
diff --git a/av1/common/cfl.c b/av1/common/cfl.c
index 5d449a3..db84ebb 100644
--- a/av1/common/cfl.c
+++ b/av1/common/cfl.c
@@ -160,6 +160,7 @@
 
 CFL_PREDICT_FN(c, lbd)
 
+#if CONFIG_AV1_HIGHBITDEPTH
 void cfl_predict_hbd_c(const int16_t *ac_buf_q3, uint16_t *dst, int dst_stride,
                        int alpha_q3, int bit_depth, int width, int height) {
   for (int j = 0; j < height; j++) {
@@ -173,6 +174,7 @@
 }
 
 CFL_PREDICT_FN(c, hbd)
+#endif
 
 static void cfl_compute_parameters(MACROBLOCKD *const xd, TX_SIZE tx_size) {
   CFL_CTX *const cfl = &xd->cfl;
@@ -196,12 +198,14 @@
       cfl_idx_to_alpha(mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs, plane - 1);
   assert((tx_size_high[tx_size] - 1) * CFL_BUF_LINE + tx_size_wide[tx_size] <=
          CFL_BUF_SQUARE);
+#if CONFIG_AV1_HIGHBITDEPTH
   if (is_cur_buf_hbd(xd)) {
     uint16_t *dst_16 = CONVERT_TO_SHORTPTR(dst);
     cfl_get_predict_hbd_fn(tx_size)(cfl->ac_buf_q3, dst_16, dst_stride,
                                     alpha_q3, xd->bd);
     return;
   }
+#endif
   cfl_get_predict_lbd_fn(tx_size)(cfl->ac_buf_q3, dst, dst_stride, alpha_q3);
 }
 
@@ -248,6 +252,7 @@
   }
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static void cfl_luma_subsampling_420_hbd_c(const uint16_t *input,
                                            int input_stride,
                                            uint16_t *output_q3, int width,
@@ -290,9 +295,11 @@
     output_q3 += CFL_BUF_LINE;
   }
 }
+#endif
 
 CFL_GET_SUBSAMPLE_FUNCTION(c)
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static INLINE cfl_subsample_hbd_fn cfl_subsampling_hbd(TX_SIZE tx_size,
                                                        int sub_x, int sub_y) {
   if (sub_x == 1) {
@@ -303,6 +310,7 @@
   }
   return cfl_get_luma_subsampling_444_hbd(tx_size);
 }
+#endif
 
 static INLINE cfl_subsample_lbd_fn cfl_subsampling_lbd(TX_SIZE tx_size,
                                                        int sub_x, int sub_y) {
@@ -348,7 +356,7 @@
   // Store the input into the CfL pixel buffer
   uint16_t *recon_buf_q3 =
       cfl->recon_buf_q3 + (store_row * CFL_BUF_LINE + store_col);
-
+#if CONFIG_AV1_HIGHBITDEPTH
   if (use_hbd) {
     cfl_subsampling_hbd(tx_size, sub_x, sub_y)(CONVERT_TO_SHORTPTR(input),
                                                input_stride, recon_buf_q3);
@@ -356,6 +364,10 @@
     cfl_subsampling_lbd(tx_size, sub_x, sub_y)(input, input_stride,
                                                recon_buf_q3);
   }
+#else
+  (void)use_hbd;
+  cfl_subsampling_lbd(tx_size, sub_x, sub_y)(input, input_stride, recon_buf_q3);
+#endif
 }
 
 // Adjust the row and column of blocks smaller than 8X8, as chroma-referenced
diff --git a/av1/common/cfl.h b/av1/common/cfl.h
index f6965ee..2acad26 100644
--- a/av1/common/cfl.h
+++ b/av1/common/cfl.h
@@ -144,6 +144,7 @@
 
 // The RTCD script does not support passing in an array, so we wrap it in this
 // function.
+#if CONFIG_AV1_HIGHBITDEPTH
 #define CFL_GET_SUBSAMPLE_FUNCTION(arch)  \
   CFL_SUBSAMPLE_FUNCTIONS(arch, 420, lbd) \
   CFL_SUBSAMPLE_FUNCTIONS(arch, 422, lbd) \
@@ -151,6 +152,12 @@
   CFL_SUBSAMPLE_FUNCTIONS(arch, 420, hbd) \
   CFL_SUBSAMPLE_FUNCTIONS(arch, 422, hbd) \
   CFL_SUBSAMPLE_FUNCTIONS(arch, 444, hbd)
+#else
+#define CFL_GET_SUBSAMPLE_FUNCTION(arch)  \
+  CFL_SUBSAMPLE_FUNCTIONS(arch, 420, lbd) \
+  CFL_SUBSAMPLE_FUNCTIONS(arch, 422, lbd) \
+  CFL_SUBSAMPLE_FUNCTIONS(arch, 444, lbd)
+#endif
 
 // Declare a size-specific wrapper for the size-generic function. The compiler
 // will inline the size generic function in here, the advantage is that the size
@@ -221,6 +228,7 @@
                            height);                                       \
   }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 #define CFL_PREDICT_hbd(arch, width, height)                                   \
   void cfl_predict_hbd_##width##x##height##_##arch(                            \
       const int16_t *pred_buf_q3, uint16_t *dst, int dst_stride, int alpha_q3, \
@@ -228,6 +236,7 @@
     cfl_predict_hbd_##arch(pred_buf_q3, dst, dst_stride, alpha_q3, bd, width,  \
                            height);                                            \
   }
+#endif
 
 // This wrapper exists because clang format does not like calling macros with
 // lowercase letters.
diff --git a/av1/common/warped_motion.c b/av1/common/warped_motion.c
index d6dcde1..8997d81 100644
--- a/av1/common/warped_motion.c
+++ b/av1/common/warped_motion.c
@@ -304,6 +304,7 @@
   return 1;
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static INLINE int highbd_error_measure(int err, int bd) {
   const int b = bd - 8;
   const int bmask = (1 << b) - 1;
@@ -503,6 +504,7 @@
   }
   return sum_error;
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 /* The warp filter for ROTZOOM and AFFINE models works as follows:
    * Split the input into 8x8 blocks
@@ -779,11 +781,15 @@
 
 int64_t av1_frame_error(int use_hbd, int bd, const uint8_t *ref, int stride,
                         uint8_t *dst, int p_width, int p_height, int p_stride) {
+#if CONFIG_AV1_HIGHBITDEPTH
   if (use_hbd) {
     return av1_calc_highbd_frame_error(CONVERT_TO_SHORTPTR(ref), stride,
                                        CONVERT_TO_SHORTPTR(dst), p_width,
                                        p_height, p_stride, bd);
   }
+#endif
+  (void)use_hbd;
+  (void)bd;
   return av1_calc_frame_error(ref, stride, dst, p_width, p_height, p_stride);
 }
 
@@ -792,11 +798,15 @@
                                   int p_height, int p_stride,
                                   uint8_t *segment_map,
                                   int segment_map_stride) {
+#if CONFIG_AV1_HIGHBITDEPTH
   if (use_hbd) {
     return highbd_segmented_frame_error(
         CONVERT_TO_SHORTPTR(ref), stride, CONVERT_TO_SHORTPTR(dst), p_width,
         p_height, p_stride, bd, segment_map, segment_map_stride);
   }
+#endif
+  (void)use_hbd;
+  (void)bd;
   return segmented_frame_error(ref, stride, dst, p_width, p_height, p_stride,
                                segment_map, segment_map_stride);
 }
@@ -806,6 +816,7 @@
                     uint8_t *pred, int p_col, int p_row, int p_width,
                     int p_height, int p_stride, int subsampling_x,
                     int subsampling_y, ConvolveParams *conv_params) {
+#if CONFIG_AV1_HIGHBITDEPTH
   if (use_hbd)
     highbd_warp_plane(wm, CONVERT_TO_SHORTPTR(ref), width, height, stride,
                       CONVERT_TO_SHORTPTR(pred), p_col, p_row, p_width,
@@ -814,6 +825,12 @@
   else
     warp_plane(wm, ref, width, height, stride, pred, p_col, p_row, p_width,
                p_height, p_stride, subsampling_x, subsampling_y, conv_params);
+#else
+  (void)use_hbd;
+  (void)bd;
+  warp_plane(wm, ref, width, height, stride, pred, p_col, p_row, p_width,
+             p_height, p_stride, subsampling_x, subsampling_y, conv_params);
+#endif
 }
 
 #define LS_MV_MAX 256  // max mv in 1/8-pel
diff --git a/av1/common/x86/cfl_avx2.c b/av1/common/x86/cfl_avx2.c
index 3356984..d9c6f99 100644
--- a/av1/common/x86/cfl_avx2.c
+++ b/av1/common/x86/cfl_avx2.c
@@ -147,6 +147,7 @@
 
 CFL_GET_SUBSAMPLE_FUNCTION_AVX2(444, lbd)
 
+#if CONFIG_AV1_HIGHBITDEPTH
 /**
  * Adds 4 pixels (in a 2x2 grid) and multiplies them by 2. Resulting in a more
  * precise version of a box filter 4:2:0 pixel subsampling in Q3.
@@ -238,6 +239,7 @@
 }
 
 CFL_GET_SUBSAMPLE_FUNCTION_AVX2(444, hbd)
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 static INLINE __m256i predict_unclipped(const __m256i *input, __m256i alpha_q12,
                                         __m256i alpha_sign, __m256i dc_q0) {
@@ -300,6 +302,7 @@
   return pred[tx_size % TX_SIZES_ALL];
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static __m256i highbd_max_epi16(int bd) {
   const __m256i neg_one = _mm256_set1_epi16(-1);
   // (1 << bd) - 1 => -(-1 << bd) -1 => -1 - (-1 << bd) => -1 ^ (-1 << bd)
@@ -372,6 +375,7 @@
   // function pointer array out of bounds.
   return pred[tx_size % TX_SIZES_ALL];
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 // Returns a vector where all the (32-bits) elements are the sum of all the
 // lanes in a.
diff --git a/av1/common/x86/cfl_simd.h b/av1/common/x86/cfl_simd.h
index f2d4ac7..03ae02a 100644
--- a/av1/common/x86/cfl_simd.h
+++ b/av1/common/x86/cfl_simd.h
@@ -98,6 +98,7 @@
 void cfl_subsample_lbd_444_16x32_ssse3(const uint8_t *cfl_type,
                                        int input_stride, uint16_t *output_q3);
 
+#if CONFIG_AV1_HIGHBITDEPTH
 void cfl_subsample_hbd_420_4x4_ssse3(const uint16_t *cfl_type, int input_stride,
                                      uint16_t *output_q3);
 void cfl_subsample_hbd_420_4x8_ssse3(const uint16_t *cfl_type, int input_stride,
@@ -178,6 +179,7 @@
                                        int input_stride, uint16_t *output_q3);
 void cfl_subsample_hbd_444_16x32_ssse3(const uint16_t *cfl_type,
                                        int input_stride, uint16_t *output_q3);
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 // SSE2 version is optimal for with == 4, we reuse them in AVX2
 void cfl_subtract_average_4x4_sse2(const uint16_t *src, int16_t *dst);
@@ -215,6 +217,7 @@
 void cfl_predict_lbd_16x32_ssse3(const int16_t *pred_buf_q3, uint8_t *dst,
                                  int dst_stride, int alpha_q3);
 
+#if CONFIG_AV1_HIGHBITDEPTH
 void cfl_predict_hbd_4x4_ssse3(const int16_t *pred_buf_q3, uint16_t *dst,
                                int dst_stride, int alpha_q3, int bd);
 void cfl_predict_hbd_4x8_ssse3(const int16_t *pred_buf_q3, uint16_t *dst,
@@ -239,5 +242,5 @@
                                  int dst_stride, int alpha_q3, int bd);
 void cfl_predict_hbd_16x32_ssse3(const int16_t *pred_buf_q3, uint16_t *dst,
                                  int dst_stride, int alpha_q3, int bd);
-
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 #endif  // AOM_AV1_COMMON_X86_CFL_SIMD_H_
diff --git a/av1/common/x86/cfl_ssse3.c b/av1/common/x86/cfl_ssse3.c
index bbf0072..476b660 100644
--- a/av1/common/x86/cfl_ssse3.c
+++ b/av1/common/x86/cfl_ssse3.c
@@ -168,6 +168,7 @@
   } while (pred_buf_m128i < end);
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 /**
  * Adds 4 pixels (in a 2x2 grid) and multiplies them by 2. Resulting in a more
  * precise version of a box filter 4:2:0 pixel subsampling in Q3.
@@ -296,6 +297,7 @@
     pred_buf_q3 += CFL_BUF_LINE;
   } while (pred_buf_q3 < end);
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 CFL_GET_SUBSAMPLE_FUNCTION(ssse3)
 
@@ -341,6 +343,7 @@
 
 CFL_PREDICT_FN(ssse3, lbd)
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static INLINE __m128i highbd_max_epi16(int bd) {
   const __m128i neg_one = _mm_set1_epi16(-1);
   // (1 << bd) - 1 => -(-1 << bd) -1 => -1 - (-1 << bd) => -1 ^ (-1 << bd)
@@ -391,3 +394,4 @@
 }
 
 CFL_PREDICT_FN(ssse3, hbd)
+#endif  // CONFIG_AV1_HIGHBITDEPTH
diff --git a/av1/encoder/global_motion.c b/av1/encoder/global_motion.c
index 9354bc5..9623ec3 100644
--- a/av1/encoder/global_motion.c
+++ b/av1/encoder/global_motion.c
@@ -161,6 +161,7 @@
   wm->wmtype = wmtype;
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static int64_t highbd_warp_error(
     WarpedMotionParams *wm, const uint16_t *const ref, int width, int height,
     int stride, const uint16_t *const dst, int p_col, int p_row, int p_width,
@@ -195,6 +196,7 @@
   }
   return gm_sumerr;
 }
+#endif
 
 static int64_t warp_error(WarpedMotionParams *wm, const uint8_t *const ref,
                           int width, int height, int stride,
@@ -242,12 +244,16 @@
                        uint8_t *segment_map, int segment_map_stride) {
   if (wm->wmtype <= AFFINE)
     if (!av1_get_shear_params(wm)) return INT64_MAX;
+#if CONFIG_AV1_HIGHBITDEPTH
   if (use_hbd)
     return highbd_warp_error(wm, CONVERT_TO_SHORTPTR(ref), width, height,
                              stride, CONVERT_TO_SHORTPTR(dst), p_col, p_row,
                              p_width, p_height, p_stride, subsampling_x,
                              subsampling_y, bd, best_error, segment_map,
                              segment_map_stride);
+#endif
+  (void)use_hbd;
+  (void)bd;
   return warp_error(wm, ref, width, height, stride, dst, p_col, p_row, p_width,
                     p_height, p_stride, subsampling_x, subsampling_y,
                     best_error, segment_map, segment_map_stride);
diff --git a/av1/encoder/pickrst.c b/av1/encoder/pickrst.c
index 6908a72..26aa211 100644
--- a/av1/encoder/pickrst.c
+++ b/av1/encoder/pickrst.c
@@ -267,6 +267,7 @@
   return err;
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 int64_t av1_highbd_pixel_proj_error_c(const uint8_t *src8, int width,
                                       int height, int src_stride,
                                       const uint8_t *dat8, int dat_stride,
@@ -340,6 +341,7 @@
   }
   return err;
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 static int64_t get_pixel_proj_error(const uint8_t *src8, int width, int height,
                                     int src_stride, const uint8_t *dat8,
@@ -349,15 +351,24 @@
                                     const sgr_params_type *params) {
   int xq[2];
   av1_decode_xq(xqd, xq, params);
-  if (!use_highbitdepth) {
-    return av1_lowbd_pixel_proj_error(src8, width, height, src_stride, dat8,
-                                      dat_stride, flt0, flt0_stride, flt1,
-                                      flt1_stride, xq, params);
-  } else {
+
+#if CONFIG_AV1_HIGHBITDEPTH
+  if (use_highbitdepth) {
     return av1_highbd_pixel_proj_error(src8, width, height, src_stride, dat8,
                                        dat_stride, flt0, flt0_stride, flt1,
                                        flt1_stride, xq, params);
+
+  } else {
+    return av1_lowbd_pixel_proj_error(src8, width, height, src_stride, dat8,
+                                      dat_stride, flt0, flt0_stride, flt1,
+                                      flt1_stride, xq, params);
   }
+#else
+  (void)use_highbitdepth;
+  return av1_lowbd_pixel_proj_error(src8, width, height, src_stride, dat8,
+                                    dat_stride, flt0, flt0_stride, flt1,
+                                    flt1_stride, xq, params);
+#endif
 }
 
 #define USE_SGRPROJ_REFINEMENT_SEARCH 1
@@ -777,6 +788,7 @@
   }
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 void av1_compute_stats_highbd_c(int wiener_win, const uint8_t *dgd8,
                                 const uint8_t *src8, int h_start, int h_end,
                                 int v_start, int v_end, int dgd_stride,
@@ -830,6 +842,7 @@
     }
   }
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 static INLINE int wrap_index(int i, int wiener_win) {
   const int wiener_halfwin1 = (wiener_win >> 1) + 1;
@@ -1272,6 +1285,7 @@
   int64_t H[WIENER_WIN2 * WIENER_WIN2];
   int32_t vfilter[WIENER_WIN], hfilter[WIENER_WIN];
 
+#if CONFIG_AV1_HIGHBITDEPTH
   const AV1_COMMON *const cm = rsc->cm;
   if (cm->seq_params.use_highbitdepth) {
     av1_compute_stats_highbd(reduced_wiener_win, rsc->dgd_buffer,
@@ -1283,7 +1297,11 @@
                       limits->h_start, limits->h_end, limits->v_start,
                       limits->v_end, rsc->dgd_stride, rsc->src_stride, M, H);
   }
-
+#else
+  av1_compute_stats(reduced_wiener_win, rsc->dgd_buffer, rsc->src_buffer,
+                    limits->h_start, limits->h_end, limits->v_start,
+                    limits->v_end, rsc->dgd_stride, rsc->src_stride, M, H);
+#endif
   const MACROBLOCK *const x = rsc->x;
   const int64_t bits_none = x->wiener_restore_cost[0];
 
diff --git a/av1/encoder/pickrst.h b/av1/encoder/pickrst.h
index f34359c..eee3055 100644
--- a/av1/encoder/pickrst.h
+++ b/av1/encoder/pickrst.h
@@ -42,6 +42,7 @@
   return (uint8_t)avg;
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static INLINE uint16_t find_average_highbd(const uint16_t *src, int h_start,
                                            int h_end, int v_start, int v_end,
                                            int stride) {
@@ -54,6 +55,7 @@
   uint64_t avg = sum / ((v_end - v_start) * (h_end - h_start));
   return (uint16_t)avg;
 }
+#endif
 
 void av1_pick_filter_restoration(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi);
 
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 7b2ae0e..ab3e631 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1881,6 +1881,7 @@
   return error;
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 int64_t av1_highbd_block_error_c(const tran_low_t *coeff,
                                  const tran_low_t *dqcoeff, intptr_t block_size,
                                  int64_t *ssz, int bd) {
@@ -1901,6 +1902,7 @@
   *ssz = sqcoeff;
   return error;
 }
+#endif
 
 // Get transform block visible dimensions cropped to the MI units.
 static AOM_INLINE void get_txb_dimensions(const MACROBLOCKD *xd, int plane,
@@ -2110,13 +2112,15 @@
   int shift = (MAX_TX_SCALE - av1_get_tx_scale(tx_size)) * 2;
   tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
   tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
-
+#if CONFIG_AV1_HIGHBITDEPTH
   if (is_cur_buf_hbd(xd))
     *out_dist = av1_highbd_block_error(coeff, dqcoeff, buffer_length, &this_sse,
                                        xd->bd);
   else
     *out_dist = av1_block_error(coeff, dqcoeff, buffer_length, &this_sse);
-
+#else
+  *out_dist = av1_block_error(coeff, dqcoeff, buffer_length, &this_sse);
+#endif
   *out_dist = RIGHT_SIGNED_SHIFT(*out_dist, shift);
   *out_sse = RIGHT_SIGNED_SHIFT(this_sse, shift);
 }
diff --git a/av1/encoder/x86/pickrst_avx2.c b/av1/encoder/x86/pickrst_avx2.c
index 5571165..e011c26 100644
--- a/av1/encoder/x86/pickrst_avx2.c
+++ b/av1/encoder/x86/pickrst_avx2.c
@@ -122,6 +122,7 @@
   }
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static INLINE void acc_stat_highbd_avx2(int64_t *dst, const uint16_t *dgd,
                                         const __m256i *shuffle,
                                         const __m256i *dgd_ijkl) {
@@ -380,6 +381,7 @@
                                v_end, dgd_stride, src_stride, M, H, bit_depth);
   }
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 static INLINE void acc_stat_win5_one_line_avx2(
     const uint8_t *dgd, const uint8_t *src, int h_start, int h_end,
@@ -628,6 +630,7 @@
   return err;
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 int64_t av1_highbd_pixel_proj_error_avx2(
     const uint8_t *src8, int width, int height, int src_stride,
     const uint8_t *dat8, int dat_stride, int32_t *flt0, int flt0_stride,
@@ -847,3 +850,4 @@
   err += sum[0] + sum[1] + sum[2] + sum[3];
   return err;
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
diff --git a/av1/encoder/x86/pickrst_sse4.c b/av1/encoder/x86/pickrst_sse4.c
index a94e169..f41694b 100644
--- a/av1/encoder/x86/pickrst_sse4.c
+++ b/av1/encoder/x86/pickrst_sse4.c
@@ -125,6 +125,7 @@
   }
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 static INLINE void acc_stat_highbd_sse41(int64_t *dst, const uint16_t *dgd,
                                          const __m128i *shuffle,
                                          const __m128i *dgd_ijkl) {
@@ -386,6 +387,7 @@
                                v_end, dgd_stride, src_stride, M, H, bit_depth);
   }
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 static INLINE void acc_stat_win5_one_line_sse4_1(
     const uint8_t *dgd, const uint8_t *src, int h_start, int h_end,
@@ -622,6 +624,7 @@
   return err;
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 int64_t av1_highbd_pixel_proj_error_sse4_1(
     const uint8_t *src8, int width, int height, int src_stride,
     const uint8_t *dat8, int dat_stride, int32_t *flt0, int flt0_stride,
@@ -827,3 +830,4 @@
   err += sum[0] + sum[1];
   return err;
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
diff --git a/test/cfl_test.cc b/test/cfl_test.cc
index fccc9f2..b2d6137 100644
--- a/test/cfl_test.cc
+++ b/test/cfl_test.cc
@@ -310,6 +310,7 @@
   subsampleSpeedTest(fun_444, fun_444_ref, &ACMRandom::Rand8);
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 typedef cfl_subsample_hbd_fn (*get_subsample_hbd_fn)(TX_SIZE tx_size);
 typedef ::testing::tuple<TX_SIZE, get_subsample_hbd_fn, get_subsample_hbd_fn,
                          get_subsample_hbd_fn>
@@ -351,6 +352,7 @@
 TEST_P(CFLSubsampleHBDTest, DISABLED_SubsampleHBD444SpeedTest) {
   subsampleSpeedTest(fun_444, fun_444_ref, &ACMRandom::Rand12);
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 typedef cfl_predict_lbd_fn (*get_predict_fn)(TX_SIZE tx_size);
 typedef ::testing::tuple<TX_SIZE, get_predict_fn> predict_param;
@@ -398,6 +400,7 @@
   assertFaster(ref_elapsed_time, elapsed_time);
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 typedef cfl_predict_hbd_fn (*get_predict_fn_hbd)(TX_SIZE tx_size);
 typedef ::testing::tuple<TX_SIZE, get_predict_fn_hbd> predict_param_hbd;
 class CFLPredictHBDTest : public ::testing::TestWithParam<predict_param_hbd>,
@@ -445,6 +448,7 @@
   printSpeed(ref_elapsed_time, elapsed_time, width, height);
   assertFaster(ref_elapsed_time, elapsed_time);
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 #if HAVE_SSE2
 const sub_avg_param sub_avg_sizes_sse2[] = { ALL_CFL_TX_SIZES(
@@ -462,30 +466,32 @@
                              cfl_get_luma_subsampling_444_lbd_ssse3)
 };
 
+const predict_param predict_sizes_ssse3[] = { ALL_CFL_TX_SIZES(
+    cfl_get_predict_lbd_fn_ssse3) };
+
+INSTANTIATE_TEST_CASE_P(SSSE3, CFLSubsampleLBDTest,
+                        ::testing::ValuesIn(subsample_lbd_sizes_ssse3));
+
+INSTANTIATE_TEST_CASE_P(SSSE3, CFLPredictTest,
+                        ::testing::ValuesIn(predict_sizes_ssse3));
+
+#if CONFIG_AV1_HIGHBITDEPTH
 const subsample_hbd_param subsample_hbd_sizes_ssse3[] = {
   ALL_CFL_TX_SIZES_SUBSAMPLE(cfl_get_luma_subsampling_420_hbd_ssse3,
                              cfl_get_luma_subsampling_422_hbd_ssse3,
                              cfl_get_luma_subsampling_444_hbd_ssse3)
 };
 
-const predict_param predict_sizes_ssse3[] = { ALL_CFL_TX_SIZES(
-    cfl_get_predict_lbd_fn_ssse3) };
-
 const predict_param_hbd predict_sizes_hbd_ssse3[] = { ALL_CFL_TX_SIZES(
     cfl_get_predict_hbd_fn_ssse3) };
 
-INSTANTIATE_TEST_CASE_P(SSSE3, CFLSubsampleLBDTest,
-                        ::testing::ValuesIn(subsample_lbd_sizes_ssse3));
-
 INSTANTIATE_TEST_CASE_P(SSSE3, CFLSubsampleHBDTest,
                         ::testing::ValuesIn(subsample_hbd_sizes_ssse3));
 
-INSTANTIATE_TEST_CASE_P(SSSE3, CFLPredictTest,
-                        ::testing::ValuesIn(predict_sizes_ssse3));
-
 INSTANTIATE_TEST_CASE_P(SSSE3, CFLPredictHBDTest,
                         ::testing::ValuesIn(predict_sizes_hbd_ssse3));
-#endif
+#endif  // CONFIG_AV1_HIGHBITDEPTH
+#endif  // HAVE_SSSE3
 
 #if HAVE_AVX2
 const sub_avg_param sub_avg_sizes_avx2[] = { ALL_CFL_TX_SIZES(
@@ -497,72 +503,75 @@
                              cfl_get_luma_subsampling_444_lbd_avx2)
 };
 
-const subsample_hbd_param subsample_hbd_sizes_avx2[] = {
-  ALL_CFL_TX_SIZES_SUBSAMPLE(cfl_get_luma_subsampling_420_hbd_avx2,
-                             cfl_get_luma_subsampling_422_hbd_avx2,
-                             cfl_get_luma_subsampling_444_hbd_avx2)
-};
-
 const predict_param predict_sizes_avx2[] = { ALL_CFL_TX_SIZES(
     cfl_get_predict_lbd_fn_avx2) };
 
-const predict_param_hbd predict_sizes_hbd_avx2[] = { ALL_CFL_TX_SIZES(
-    cfl_get_predict_hbd_fn_avx2) };
-
 INSTANTIATE_TEST_CASE_P(AVX2, CFLSubAvgTest,
                         ::testing::ValuesIn(sub_avg_sizes_avx2));
 
 INSTANTIATE_TEST_CASE_P(AVX2, CFLSubsampleLBDTest,
                         ::testing::ValuesIn(subsample_lbd_sizes_avx2));
 
-INSTANTIATE_TEST_CASE_P(AVX2, CFLSubsampleHBDTest,
-                        ::testing::ValuesIn(subsample_hbd_sizes_avx2));
-
 INSTANTIATE_TEST_CASE_P(AVX2, CFLPredictTest,
                         ::testing::ValuesIn(predict_sizes_avx2));
 
+#if CONFIG_AV1_HIGHBITDEPTH
+const subsample_hbd_param subsample_hbd_sizes_avx2[] = {
+  ALL_CFL_TX_SIZES_SUBSAMPLE(cfl_get_luma_subsampling_420_hbd_avx2,
+                             cfl_get_luma_subsampling_422_hbd_avx2,
+                             cfl_get_luma_subsampling_444_hbd_avx2)
+};
+
+const predict_param_hbd predict_sizes_hbd_avx2[] = { ALL_CFL_TX_SIZES(
+    cfl_get_predict_hbd_fn_avx2) };
+
+INSTANTIATE_TEST_CASE_P(AVX2, CFLSubsampleHBDTest,
+                        ::testing::ValuesIn(subsample_hbd_sizes_avx2));
+
 INSTANTIATE_TEST_CASE_P(AVX2, CFLPredictHBDTest,
                         ::testing::ValuesIn(predict_sizes_hbd_avx2));
-#endif
+#endif  // CONFIG_AV1_HIGHBITDEPTH
+#endif  // HAVE_AVX2
 
 #if HAVE_NEON
-
 const sub_avg_param sub_avg_sizes_neon[] = { ALL_CFL_TX_SIZES(
     cfl_get_subtract_average_fn_neon) };
 
+const predict_param predict_sizes_neon[] = { ALL_CFL_TX_SIZES(
+    cfl_get_predict_lbd_fn_neon) };
+
 const subsample_lbd_param subsample_lbd_sizes_neon[] = {
   ALL_CFL_TX_SIZES_SUBSAMPLE(cfl_get_luma_subsampling_420_lbd_neon,
                              cfl_get_luma_subsampling_422_lbd_neon,
                              cfl_get_luma_subsampling_444_lbd_neon)
 };
 
-const subsample_hbd_param subsample_hbd_sizes_neon[] = {
-  ALL_CFL_TX_SIZES_SUBSAMPLE(cfl_get_luma_subsampling_420_hbd_neon,
-                             cfl_get_luma_subsampling_422_hbd_neon,
-                             cfl_get_luma_subsampling_444_hbd_neon)
-};
-
-const predict_param predict_sizes_neon[] = { ALL_CFL_TX_SIZES(
-    cfl_get_predict_lbd_fn_neon) };
-
-const predict_param_hbd predict_sizes_hbd_neon[] = { ALL_CFL_TX_SIZES(
-    cfl_get_predict_hbd_fn_neon) };
-
 INSTANTIATE_TEST_CASE_P(NEON, CFLSubAvgTest,
                         ::testing::ValuesIn(sub_avg_sizes_neon));
 
 INSTANTIATE_TEST_CASE_P(NEON, CFLSubsampleLBDTest,
                         ::testing::ValuesIn(subsample_lbd_sizes_neon));
 
-INSTANTIATE_TEST_CASE_P(NEON, CFLSubsampleHBDTest,
-                        ::testing::ValuesIn(subsample_hbd_sizes_neon));
-
 INSTANTIATE_TEST_CASE_P(NEON, CFLPredictTest,
                         ::testing::ValuesIn(predict_sizes_neon));
 
+#if CONFIG_AV1_HIGHBITDEPTH
+const subsample_hbd_param subsample_hbd_sizes_neon[] = {
+  ALL_CFL_TX_SIZES_SUBSAMPLE(cfl_get_luma_subsampling_420_hbd_neon,
+                             cfl_get_luma_subsampling_422_hbd_neon,
+                             cfl_get_luma_subsampling_444_hbd_neon)
+};
+
+const predict_param_hbd predict_sizes_hbd_neon[] = { ALL_CFL_TX_SIZES(
+    cfl_get_predict_hbd_fn_neon) };
+
+INSTANTIATE_TEST_CASE_P(NEON, CFLSubsampleHBDTest,
+                        ::testing::ValuesIn(subsample_hbd_sizes_neon));
+
 INSTANTIATE_TEST_CASE_P(NEON, CFLPredictHBDTest,
                         ::testing::ValuesIn(predict_sizes_hbd_neon));
-#endif
+#endif  // CONFIG_AV1_HIGHBITDEPTH
+#endif  // HAVE_NEON
 
 #if HAVE_VSX
 const sub_avg_param sub_avg_sizes_vsx[] = { ALL_CFL_TX_SIZES(
diff --git a/test/error_block_test.cc b/test/error_block_test.cc
index da2ceba..85ec076 100644
--- a/test/error_block_test.cc
+++ b/test/error_block_test.cc
@@ -237,29 +237,33 @@
 #if (HAVE_SSE2)
 INSTANTIATE_TEST_CASE_P(
     SSE2, ErrorBlockTest,
-    ::testing::Values(make_tuple(&av1_highbd_block_error_sse2,
-                                 &av1_highbd_block_error_c, AOM_BITS_10),
-                      make_tuple(&av1_highbd_block_error_sse2,
-                                 &av1_highbd_block_error_c, AOM_BITS_12),
-                      make_tuple(&av1_highbd_block_error_sse2,
-                                 &av1_highbd_block_error_c, AOM_BITS_8),
-                      make_tuple(&BlockError8BitWrapper<av1_block_error_sse2>,
-                                 &BlockError8BitWrapper<av1_block_error_c>,
-                                 AOM_BITS_8)));
+    ::testing::Values(
+#if CONFIG_AV1_HIGHBITDEPTH
+        make_tuple(&av1_highbd_block_error_sse2, &av1_highbd_block_error_c,
+                   AOM_BITS_10),
+        make_tuple(&av1_highbd_block_error_sse2, &av1_highbd_block_error_c,
+                   AOM_BITS_12),
+        make_tuple(&av1_highbd_block_error_sse2, &av1_highbd_block_error_c,
+                   AOM_BITS_8),
+#endif
+        make_tuple(&BlockError8BitWrapper<av1_block_error_sse2>,
+                   &BlockError8BitWrapper<av1_block_error_c>, AOM_BITS_8)));
 #endif  // HAVE_SSE2
 
 #if (HAVE_AVX2)
 INSTANTIATE_TEST_CASE_P(
     AVX2, ErrorBlockTest,
-    ::testing::Values(make_tuple(&av1_highbd_block_error_avx2,
-                                 &av1_highbd_block_error_c, AOM_BITS_10),
-                      make_tuple(&av1_highbd_block_error_avx2,
-                                 &av1_highbd_block_error_c, AOM_BITS_12),
-                      make_tuple(&av1_highbd_block_error_avx2,
-                                 &av1_highbd_block_error_c, AOM_BITS_8),
-                      make_tuple(&BlockError8BitWrapper<av1_block_error_avx2>,
-                                 &BlockError8BitWrapper<av1_block_error_c>,
-                                 AOM_BITS_8)));
+    ::testing::Values(
+#if CONFIG_AV1_HIGHBITDEPTH
+        make_tuple(&av1_highbd_block_error_avx2, &av1_highbd_block_error_c,
+                   AOM_BITS_10),
+        make_tuple(&av1_highbd_block_error_avx2, &av1_highbd_block_error_c,
+                   AOM_BITS_12),
+        make_tuple(&av1_highbd_block_error_avx2, &av1_highbd_block_error_c,
+                   AOM_BITS_8),
+#endif
+        make_tuple(&BlockError8BitWrapper<av1_block_error_avx2>,
+                   &BlockError8BitWrapper<av1_block_error_c>, AOM_BITS_8)));
 #endif  // HAVE_AVX2
 
 #if (HAVE_MSA)
diff --git a/test/pickrst_test.cc b/test/pickrst_test.cc
index 0aa49b6..a4da28c 100644
--- a/test/pickrst_test.cc
+++ b/test/pickrst_test.cc
@@ -189,6 +189,7 @@
 
 }  // namespace pickrst_test_lowbd
 
+#if CONFIG_AV1_HIGHBITDEPTH
 namespace pickrst_test_highbd {
 static const int kIterations = 100;
 
@@ -355,3 +356,4 @@
 #endif  // HAVE_AVX2
 
 }  // namespace pickrst_test_highbd
+#endif  // CONFIG_AV1_HIGHBITDEPTH
diff --git a/test/warp_filter_test.cc b/test/warp_filter_test.cc
index cafb344..cb7ba04 100644
--- a/test/warp_filter_test.cc
+++ b/test/warp_filter_test.cc
@@ -11,7 +11,9 @@
 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
 #include "test/warp_filter_test_util.h"
 using libaom_test::ACMRandom;
+#if CONFIG_AV1_HIGHBITDEPTH
 using libaom_test::AV1HighbdWarpFilter::AV1HighbdWarpFilterTest;
+#endif
 using libaom_test::AV1WarpFilter::AV1WarpFilterTest;
 using ::testing::make_tuple;
 using ::testing::tuple;
@@ -34,6 +36,7 @@
     SSE4_1, AV1WarpFilterTest,
     libaom_test::AV1WarpFilter::BuildParams(av1_warp_affine_sse4_1));
 
+#if CONFIG_AV1_HIGHBITDEPTH
 TEST_P(AV1HighbdWarpFilterTest, CheckOutput) {
   RunCheckOutput(::testing::get<4>(GET_PARAM(0)));
 }
@@ -44,7 +47,7 @@
 INSTANTIATE_TEST_CASE_P(SSE4_1, AV1HighbdWarpFilterTest,
                         libaom_test::AV1HighbdWarpFilter::BuildParams(
                             av1_highbd_warp_affine_sse4_1));
-
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 #endif  // HAVE_SSE4_1
 
 #if HAVE_AVX2
diff --git a/test/warp_filter_test_util.cc b/test/warp_filter_test_util.cc
index 9208af8..91d040a 100644
--- a/test/warp_filter_test_util.cc
+++ b/test/warp_filter_test_util.cc
@@ -276,6 +276,7 @@
 }
 }  // namespace AV1WarpFilter
 
+#if CONFIG_AV1_HIGHBITDEPTH
 namespace AV1HighbdWarpFilter {
 ::testing::internal::ParamGenerator<HighbdWarpTestParams> BuildParams(
     highbd_warp_affine_func filter) {
@@ -477,4 +478,5 @@
   delete[] dstb;
 }
 }  // namespace AV1HighbdWarpFilter
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 }  // namespace libaom_test
diff --git a/test/warp_filter_test_util.h b/test/warp_filter_test_util.h
index b8998e5..23749fb 100644
--- a/test/warp_filter_test_util.h
+++ b/test/warp_filter_test_util.h
@@ -63,6 +63,7 @@
 
 }  // namespace AV1WarpFilter
 
+#if CONFIG_AV1_HIGHBITDEPTH
 namespace AV1HighbdWarpFilter {
 typedef void (*highbd_warp_affine_func)(const int32_t *mat, const uint16_t *ref,
                                         int width, int height, int stride,
@@ -97,6 +98,7 @@
 };
 
 }  // namespace AV1HighbdWarpFilter
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 }  // namespace libaom_test
 
diff --git a/test/wiener_test.cc b/test/wiener_test.cc
index 8f49af62..68bf3ad 100644
--- a/test/wiener_test.cc
+++ b/test/wiener_test.cc
@@ -284,6 +284,7 @@
 
 }  // namespace wiener_lowbd
 
+#if CONFIG_AV1_HIGHBITDEPTH
 // High bit-depth tests:
 namespace wiener_highbd {
 
@@ -582,3 +583,4 @@
 #endif  // HAVE_AVX2
 
 }  // namespace wiener_highbd
+#endif  // CONFIG_AV1_HIGHBITDEPTH