diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def
index 04f3812326e..bf6825c5d00 100644
--- a/gcc/internal-fn.def
+++ b/gcc/internal-fn.def
@@ -34,10 +34,12 @@ along with GCC; see the file COPYING3.  If not see
 				   UNSIGNED_OPTAB, TYPE)
      DEF_INTERNAL_FLT_FN (NAME, FLAGS, OPTAB, TYPE)
      DEF_INTERNAL_INT_FN (NAME, FLAGS, OPTAB, TYPE)
+     DEF_INTERNAL_COND_FN (NAME, FLAGS, OPTAB, TYPE)
+     DEF_INTERNAL_SIGNED_COND_FN (NAME, FLAGS, OPTAB, TYPE)
 
    where NAME is the name of the function, FLAGS is a set of
    ECF_* flags and FNSPEC is a string describing functions fnspec.
-   
+
    DEF_INTERNAL_OPTAB_FN defines an internal function that maps to a
    direct optab.  The function should only be called with a given
    set of types if the associated optab is available for the modes
@@ -74,7 +76,8 @@ along with GCC; see the file COPYING3.  If not see
 
    - cond_len_unary: a conditional unary optab, such as cond_len_neg<mode>
    - cond_len_binary: a conditional binary optab, such as cond_len_add<mode>
-   - cond_len_ternary: a conditional ternary optab, such as cond_len_fma_rev<mode>
+   - cond_len_ternary: a conditional ternary optab, such as
+   cond_len_fma_rev<mode>
 
    DEF_INTERNAL_SIGNED_OPTAB_FN defines an internal function that
    maps to one of two optabs, depending on the signedness of an input.
@@ -106,6 +109,16 @@ along with GCC; see the file COPYING3.  If not see
    These five internal functions will require two optabs each, a SIGNED_OPTAB
    and an UNSIGNED_OTPAB.
 
+   DEF_INTERNAL_COND_FN is a wrapper that defines 2 internal functions with
+   DEF_INTERNAL_OPTAB_FN:
+   - One is COND_* operations that are predicated by mask only. Such operations
+     make sense for both vectors and scalars.
+   - The other is COND_LEN_* operations that are predicated by mask and len
+     both. Such operations only make sense for vectors.
+
+   DEF_INTERNAL_SIGNED_COND_FN is like DEF_INTERNAL_COND_FN but defines intenal
+   functions with DEF_INTERNAL_SIGNED_OPTAB_FN.
+
    Each entry must have a corresponding expander of the form:
 
      void expand_NAME (gimple_call stmt)
@@ -153,6 +166,24 @@ along with GCC; see the file COPYING3.  If not see
   DEF_INTERNAL_SIGNED_OPTAB_FN (NAME ## _ODD, FLAGS, SELECTOR, SOPTAB##_odd, UOPTAB##_odd, TYPE)
 #endif
 
+#ifndef DEF_INTERNAL_COND_FN
+#define DEF_INTERNAL_COND_FN(NAME, FLAGS, OPTAB, TYPE)                         \
+  DEF_INTERNAL_OPTAB_FN (COND_##NAME, FLAGS, cond_##OPTAB, cond_##TYPE)        \
+  DEF_INTERNAL_OPTAB_FN (COND_LEN_##NAME, FLAGS, cond_len_##OPTAB,             \
+			 cond_len_##TYPE)
+#endif
+
+#ifndef DEF_INTERNAL_SIGNED_COND_FN
+#define DEF_INTERNAL_SIGNED_COND_FN(NAME, FLAGS, SELECTOR, SIGNED_OPTAB,       \
+				    UNSIGNED_OPTAB, TYPE)                      \
+  DEF_INTERNAL_SIGNED_OPTAB_FN (COND_##NAME, FLAGS, SELECTOR,                  \
+				cond_##SIGNED_OPTAB, cond_##UNSIGNED_OPTAB,    \
+				cond_##TYPE)                                   \
+  DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_##NAME, FLAGS, SELECTOR,              \
+				cond_len_##SIGNED_OPTAB,                       \
+				cond_len_##UNSIGNED_OPTAB, cond_len_##TYPE)
+#endif
+
 DEF_INTERNAL_OPTAB_FN (MASK_LOAD, ECF_PURE, maskload, mask_load)
 DEF_INTERNAL_OPTAB_FN (LOAD_LANES, ECF_CONST, vec_load_lanes, load_lanes)
 DEF_INTERNAL_OPTAB_FN (MASK_LOAD_LANES, ECF_PURE,
@@ -220,71 +251,29 @@ DEF_INTERNAL_SIGNED_OPTAB_FN (MULHS, ECF_CONST | ECF_NOTHROW, first,
 DEF_INTERNAL_SIGNED_OPTAB_FN (MULHRS, ECF_CONST | ECF_NOTHROW, first,
 			      smulhrs, umulhrs, binary)
 
-DEF_INTERNAL_OPTAB_FN (COND_ADD, ECF_CONST, cond_add, cond_binary)
-DEF_INTERNAL_OPTAB_FN (COND_SUB, ECF_CONST, cond_sub, cond_binary)
-DEF_INTERNAL_OPTAB_FN (COND_MUL, ECF_CONST, cond_smul, cond_binary)
-DEF_INTERNAL_SIGNED_OPTAB_FN (COND_DIV, ECF_CONST, first,
-			      cond_sdiv, cond_udiv, cond_binary)
-DEF_INTERNAL_SIGNED_OPTAB_FN (COND_MOD, ECF_CONST, first,
-			      cond_smod, cond_umod, cond_binary)
-DEF_INTERNAL_OPTAB_FN (COND_RDIV, ECF_CONST, cond_sdiv, cond_binary)
-DEF_INTERNAL_SIGNED_OPTAB_FN (COND_MIN, ECF_CONST, first,
-			      cond_smin, cond_umin, cond_binary)
-DEF_INTERNAL_SIGNED_OPTAB_FN (COND_MAX, ECF_CONST, first,
-			      cond_smax, cond_umax, cond_binary)
-DEF_INTERNAL_OPTAB_FN (COND_FMIN, ECF_CONST, cond_fmin, cond_binary)
-DEF_INTERNAL_OPTAB_FN (COND_FMAX, ECF_CONST, cond_fmax, cond_binary)
-DEF_INTERNAL_OPTAB_FN (COND_AND, ECF_CONST | ECF_NOTHROW,
-		       cond_and, cond_binary)
-DEF_INTERNAL_OPTAB_FN (COND_IOR, ECF_CONST | ECF_NOTHROW,
-		       cond_ior, cond_binary)
-DEF_INTERNAL_OPTAB_FN (COND_XOR, ECF_CONST | ECF_NOTHROW,
-		       cond_xor, cond_binary)
-DEF_INTERNAL_OPTAB_FN (COND_SHL, ECF_CONST | ECF_NOTHROW,
-		       cond_ashl, cond_binary)
-DEF_INTERNAL_SIGNED_OPTAB_FN (COND_SHR, ECF_CONST | ECF_NOTHROW, first,
-			      cond_ashr, cond_lshr, cond_binary)
-
-DEF_INTERNAL_OPTAB_FN (COND_FMA, ECF_CONST, cond_fma, cond_ternary)
-DEF_INTERNAL_OPTAB_FN (COND_FMS, ECF_CONST, cond_fms, cond_ternary)
-DEF_INTERNAL_OPTAB_FN (COND_FNMA, ECF_CONST, cond_fnma, cond_ternary)
-DEF_INTERNAL_OPTAB_FN (COND_FNMS, ECF_CONST, cond_fnms, cond_ternary)
-
-DEF_INTERNAL_OPTAB_FN (COND_NEG, ECF_CONST, cond_neg, cond_unary)
-
-DEF_INTERNAL_OPTAB_FN (COND_LEN_ADD, ECF_CONST, cond_len_add, cond_len_binary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_SUB, ECF_CONST, cond_len_sub, cond_len_binary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_MUL, ECF_CONST, cond_len_smul, cond_len_binary)
-DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_DIV, ECF_CONST, first, cond_len_sdiv,
-			      cond_len_udiv, cond_len_binary)
-DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_MOD, ECF_CONST, first, cond_len_smod,
-			      cond_len_umod, cond_len_binary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_RDIV, ECF_CONST, cond_len_sdiv, cond_len_binary)
-DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_MIN, ECF_CONST, first, cond_len_smin,
-			      cond_len_umin, cond_len_binary)
-DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_MAX, ECF_CONST, first, cond_len_smax,
-			      cond_len_umax, cond_len_binary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_FMIN, ECF_CONST, cond_len_fmin, cond_len_binary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_FMAX, ECF_CONST, cond_len_fmax, cond_len_binary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_AND, ECF_CONST | ECF_NOTHROW, cond_len_and,
-		       cond_len_binary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_IOR, ECF_CONST | ECF_NOTHROW, cond_len_ior,
-		       cond_len_binary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_XOR, ECF_CONST | ECF_NOTHROW, cond_len_xor,
-		       cond_len_binary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_SHL, ECF_CONST | ECF_NOTHROW, cond_len_ashl,
-		       cond_len_binary)
-DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_SHR, ECF_CONST | ECF_NOTHROW, first,
-			      cond_len_ashr, cond_len_lshr, cond_len_binary)
-
-DEF_INTERNAL_OPTAB_FN (COND_LEN_FMA, ECF_CONST, cond_len_fma, cond_len_ternary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_FMS, ECF_CONST, cond_len_fms, cond_len_ternary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_FNMA, ECF_CONST, cond_len_fnma,
-		       cond_len_ternary)
-DEF_INTERNAL_OPTAB_FN (COND_LEN_FNMS, ECF_CONST, cond_len_fnms,
-		       cond_len_ternary)
-
-DEF_INTERNAL_OPTAB_FN (COND_LEN_NEG, ECF_CONST, cond_len_neg, cond_len_unary)
+DEF_INTERNAL_COND_FN (ADD, ECF_CONST, add, binary)
+DEF_INTERNAL_COND_FN (SUB, ECF_CONST, sub, binary)
+DEF_INTERNAL_COND_FN (MUL, ECF_CONST, smul, binary)
+DEF_INTERNAL_SIGNED_COND_FN (DIV, ECF_CONST, first, sdiv, udiv, binary)
+DEF_INTERNAL_SIGNED_COND_FN (MOD, ECF_CONST, first, smod, umod, binary)
+DEF_INTERNAL_COND_FN (RDIV, ECF_CONST, sdiv, binary)
+DEF_INTERNAL_SIGNED_COND_FN (MIN, ECF_CONST, first, smin, umin, binary)
+DEF_INTERNAL_SIGNED_COND_FN (MAX, ECF_CONST, first, smax, umax, binary)
+DEF_INTERNAL_COND_FN (FMIN, ECF_CONST, fmin, binary)
+DEF_INTERNAL_COND_FN (FMAX, ECF_CONST, fmax, binary)
+DEF_INTERNAL_COND_FN (AND, ECF_CONST | ECF_NOTHROW, and, binary)
+DEF_INTERNAL_COND_FN (IOR, ECF_CONST | ECF_NOTHROW, ior, binary)
+DEF_INTERNAL_COND_FN (XOR, ECF_CONST | ECF_NOTHROW, xor, binary)
+DEF_INTERNAL_COND_FN (SHL, ECF_CONST | ECF_NOTHROW, ashl, binary)
+DEF_INTERNAL_SIGNED_COND_FN (SHR, ECF_CONST | ECF_NOTHROW, first, ashr, lshr,
+			     binary)
+
+DEF_INTERNAL_COND_FN (FMA, ECF_CONST, fma, ternary)
+DEF_INTERNAL_COND_FN (FMS, ECF_CONST, fms, ternary)
+DEF_INTERNAL_COND_FN (FNMA, ECF_CONST, fnma, ternary)
+DEF_INTERNAL_COND_FN (FNMS, ECF_CONST, fnms, ternary)
+
+DEF_INTERNAL_COND_FN (NEG, ECF_CONST, neg, unary)
 
 DEF_INTERNAL_OPTAB_FN (RSQRT, ECF_CONST, rsqrt, unary)
 
