diff mbox series

[x86,SSE] Improve handling of ternlog instructions in i386/sse.md (v3)

Message ID 000801dab7f9$5a61ceb0$0f256c10$@nextmovesoftware.com
State New
Headers show
Series [x86,SSE] Improve handling of ternlog instructions in i386/sse.md (v3) | expand

Commit Message

Roger Sayle June 6, 2024, 10:07 a.m. UTC
Hi Hongtao,
Here's the third revision of my improved ternlog handling patch for x86.
This addresses the previously discovered problems, adding a check for
memory_operand, and adds four new test cases, to confirm that the
appropriate functionality is being triggered/covered, including a test
case for the example you reported requiring the memory_operand fix.
[Thanks to Alexander Monakov for suggesting I use my ternlog benchmark
as a coverage testcase.]

This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
and make -k check, both with and without --target_board=unix{-m32}
with no new failures.  Ok for mainline?


2024-06-06  Roger Sayle  <roger@nextmovesoftware.com>
            Hongtao Liu  <hongtao.liu@intel.com>

gcc/ChangeLog
        * config/i386/i386-expand.cc (ix86_expand_args_builtin): Call
        fixup_modeless_constant before testing predicates.  Only call
        copy_to_mode_reg on memory operands (after the first one).
        (ix86_gen_bcst_mem): Helper function to convert a CONST_VECTOR
        into a VEC_DUPLICATE if possible.
        (ix86_ternlog_idx):  Convert an RTX expression into a ternlog
        index between 0 and 255, recording the operands in ARGS, if
        possible or return -1 if this is not possible/valid.
        (ix86_ternlog_leaf_p): Helper function to identify "leaves"
        of a ternlog expression, e.g. REG_P, MEM_P, CONST_VECTOR, etc.
        (ix86_ternlog_operand_p): Test whether a expression is suitable
        for and prefered as an UNSPEC_TERNLOG.
        (ix86_expand_ternlog_binop): Helper function to construct the
        binary operation corresponding to a sufficiently simple ternlog.
        (ix86_expand_ternlog_andnot): Helper function to construct a
        ANDN operation corresponding to a sufficiently simple ternlog.
        (ix86_expand_ternlog): Expand a 3-operand ternary logic
        expression, constructing either an UNSPEC_TERNLOG or simpler
        rtx expression.  Called from builtin expanders and pre-reload
        splitters.
        * config/i386/i386-protos.h (ix86_ternlog_idx): Prototype here.
        (ix86_ternlog_operand_p): Likewise.
        (ix86_expand_ternlog): Likewise.
        * config/i386/predicates.md (ternlog_operand): New predicate
        that calls xi86_ternlog_operand_p.
        * config/i386/sse.md (<avx512>_vpternlog<mode>_0): New
        define_insn_and_split that recognizes a SET_SRC of ternlog_operand
        and expands it via ix86_expand_ternlog pre-reload.
        (<avx512>_vternlog<mode>_mask): Convert from define_insn to
        define_expand.  Use ix86_expand_ternlog if the mask operand is
        ~0 (or 255 or -1).
        (*<avx512>_vternlog<mode>_mask): define_insn renamed from above.

gcc/testsuite/ChangeLog
        * gcc.target/i386/avx512f-vpternlogd-1.c: Update test case.
        * gcc.target/i386/avx512f-vpternlogq-1.c: Likewise.
        * gcc.target/i386/avx512vl-vpternlogd-1.c: Likewise.
        * gcc.target/i386/avx512vl-vpternlogq-1.c: Likewise.
        * gcc.target/i386/pr100711-4.c: Likewise.
        * gcc.target/i386/pr100711-5.c: Likewise.

        * gcc.target/i386/avx512f-vpternlogd-3.c: New 128-bit test case.
        * gcc.target/i386/avx512f-vpternlogd-4.c: New 256-bit test case.
        * gcc.target/i386/avx512f-vpternlogd-5.c: New 512-bit test case.
        * gcc.target/i386/avx512f-vpternlogq-3.c: New test case.


Thanks in advance,
Roger

> -----Original Message-----
> From: Hongtao Liu <crazylht@gmail.com>
> On Mon, May 27, 2024 at 2:48 PM Hongtao Liu <crazylht@gmail.com> wrote:
> >
> > On Sat, May 18, 2024 at 4:10 AM Roger Sayle <roger@nextmovesoftware.com>
> wrote:
> > >
> > >
> > > Hi Hongtao,
> > > Many thanks for the review, bug fixes and suggestions for improvements.
> > > This revised version of the patch, implements all of your
> > > corrections.  In theory the "ternlog idx" should guarantee that some
> > > operands are non-null, but I agree that it's better defensive programming to
> check invariants not easily proved.
> > > Instead of calling ix86_expand_vector_move, I use
> > > ix86_broadcast_from_constant to achieve the same effect of using a
> > > broadcast when possible, but has the benefit of still using a memory
> > > operand (instead of a vector load) when broadcasting isn't possible.
> > > There are other places that could benefit from the same trick, but I
> > > can address these in a follow-up patch (it may even be preferrable
> > > to keep these as CONST_VECTOR during early RTL passes and lower to
> broadcast or constant pool using splitters).
> > >
> > > This revised patch has been tested on x86_64-pc-linux-gnu with make
> > > bootstrap and make -k check, both with and without
> > > --target_board=unix{-m32} with no new failures.  Ok for mainline?
> > 1 file changed, 41 insertions(+)
> > gcc/config/i386/i386-expand.cc | 41
> > +++++++++++++++++++++++++++++++++++++++++
> >
> > modified   gcc/config/i386/i386-expand.cc
> > @@ -25579,14 +25579,22 @@ ix86_gen_bcst_mem (machine_mode mode, rtx
> x)
> >        && !CONST_DOUBLE_P (cst)
> >        && !CONST_FIXED_P (cst))
> >      return NULL_RTX;
> > +  /* I think VALID_BCST_MODE_P should be sufficient to
> > +     make sure cst is CONST_INT or CONST_DOUBLE.  */
> >
> >    int n_elts = GET_MODE_NUNITS (mode);
> >    if (CONST_VECTOR_NUNITS (x) != n_elts)
> >      return NULL_RTX;
> > +  /* Do we need this? I saw from caller side there's already
> > +       if (GET_MODE (op2) != mode)
> > + op2 = gen_lowpart (mode, op2);
> > + tmp2 = ix86_gen_bcst_mem (mode, op2);  */
> > +
> >
> >    for (int i = 1; i < n_elts; i++)
> >      if (!rtx_equal_p (cst, CONST_VECTOR_ELT (x, i)))
> >        return NULL_RTX;
> > +  /* CONST_VECTOR_DUPLICATE_P (op)? */
> >
> >    rtx mem = force_const_mem (GET_MODE_INNER (mode), cst);
> >    return gen_rtx_VEC_DUPLICATE (mode, validize_mem (mem)); @@
> > -25709,6 +25717,21 @@ ix86_ternlog_idx (rtx op, rtx *args)
> >     || ix86_ternlog_idx (XVECEXP (op, 0, 2), args) != 0xaa)
> >   return -1;
> >        return INTVAL (XVECEXP (op, 0, 3));
> > +      /* I think we can add some testcase for this.
> > + .i.e
> > + #include <immintrin.h>
> > +
> > + __m256i
> > + foo (__m256i a, __m256i b, __m256i c) { return (a &
> > + _mm256_ternarylogic_epi64 (a, b, c, 0xe4)); }
> > +
> > + __m256i
> > + foo1 (__m256i a, __m256i b, __m256i c) { return (b &
> > + _mm256_ternarylogic_epi64 (a, b, c, 0xe4)); }  */
> >
> >      default:
> >        return -1;
> > @@ -25778,6 +25801,8 @@ ix86_ternlog_operand_p (rtx op)
> >        if (ix86_ternlog_leaf_p (XEXP (op, 0), mode)
> >     && (ix86_ternlog_leaf_p (op1, mode)
> >         || vector_all_ones_operand (op1, mode)))
> > + /* There's CONST_VECTOR check in x86_ternlog_leaf_p,
> > +    so vector_all_ones_operand is not needed.  */
> >   return false;
> >        break;
> >
> > @@ -25862,6 +25887,10 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > op0, rtx op1, rtx op2, int idx,
> >        if ((!op0 || !side_effects_p (op0))
> >            && (!op1 || !side_effects_p (op1))
> >            && (!op2 || !side_effects_p (op2)))
> > + /* I think only op2 needs to check side_effects_p, op0
> > +    and op1 must be register operand when it exists, no need for
> > side_effects_p?
> > +    Similar for all below side_effects_p (op0/op1)
> > +    the check is redundant.  */
> >          {
> >     emit_move_insn (target, CONST0_RTX (mode));
> >     return target;
> > @@ -25872,6 +25901,9 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > op0, rtx op1, rtx op2, int idx,
> >        if ((!op1 || !side_effects_p (op1))
> >     && op0 && register_operand (op0, mode)
> >     && op2 && register_operand (op2, mode))
> > + /* op0/op1 must be register_operand when it exists,
> > +    so register_operand (op0/op1, mode) is not needed.
> > +    similar for all below register_operand (op0/op1, mode).  */
> >   return ix86_expand_ternlog_andnot (mode, op0, op2, target);
> >        break;
> >
> > @@ -25879,6 +25911,7 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > op0, rtx op1, rtx op2, int idx,
> >        if ((!op2 || !side_effects_p (op2))
> >     && op0 && register_operand (op0, mode)
> >     && op1 && register_operand (op1, mode))
> > + /* op0 && op1? */
> >   return ix86_expand_ternlog_andnot (mode, op0, op1, target);
> >        break;
> >
> > @@ -25948,6 +25981,7 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > op0, rtx op1, rtx op2, int idx,
> >        if ((!op0 || !side_effects_p (op0))
> >     && (!op1 || !side_effects_p (op1))
> >            && op2)
> > + /* if (op2).  */
> >   {
> >     if (GET_MODE (op2) != mode)
> >       op2 = gen_lowpart (mode, op2);
> > @@ -25961,18 +25995,21 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > op0, rtx op1, rtx op2, int idx,
> >      case 0x5a:  /* a^c */
> >        if (op0 && op2
> >            && (!op1 || !side_effects_p (op1)))
> > + /* if (op0 && op2).  */
> >   return ix86_expand_ternlog_binop (XOR, mode, op0, op2, target);
> >        break;
> >
> >      case 0x66:  /* b^c */
> >        if ((!op0 || !side_effects_p (op0))
> >            && op1 && op2)
> > + /* if (op1 && op2).  */
> >   return ix86_expand_ternlog_binop (XOR, mode, op1, op2, target);
> >        break;
> >
> >      case 0x88:  /* b&c */
> >        if ((!op0 || !side_effects_p (op0))
> >            && op1 && op2)
> > + /* if (op1 && op2).  */
> >   return ix86_expand_ternlog_binop (AND, mode, op1, op2, target);
> >        break;
> >
> > @@ -26054,6 +26091,9 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > op0, rtx op1, rtx op2, int idx,
> >      }
> >
> >    tmp0 = register_operand (op0, mode) ? op0 : force_reg (mode, op0);
> > +  /* Do you observe there're cases of op0 not register_operand?.
> > +     if it's from <avx512>_vternlog<mode>_mask, it must be register_operand.
> > +     if it's from ix86_ternlog_idx, it must REG_P.  */
> >    if (GET_MODE (tmp0) != mode)
> >      tmp0 = gen_lowpart (mode, tmp0);
> >
> > @@ -26061,6 +26101,7 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > op0, rtx op1, rtx op2, int idx,
> >      tmp1 = copy_rtx (tmp0);
> >    else if (!register_operand (op1, mode))
> >      tmp1 = force_reg (mode, op1);
> > +  /* Ditto.  */
> >    else
> >      tmp1 = op1;
> >    if (GET_MODE (tmp1) != mode)
> >
> >
> >
> >
> > --
> > BR,
> > Hongtao
> 
> Got ICE for below testcase
> 
> #include <immintrin.h>
> __m256i
> foo2 (__m256i** a, __m256i b)
> {
>   return ~(**a);
> }
> 
> with -march=x86-64-v4 -O2
> 
>  (insn 17 7 13 2 (set (reg:V4DI 103 [ _5 ])
>         (xor:V4DI (mem:V4DI (mem/f:DI (reg:DI 105) [1 *a_4(D)+0 S8
> A64]) [0 *_1+0 S32 A256])
>             (const_vector:V4DI [
>                     (const_int -1 [0xffffffffffffffff]) repeated x4
>                 ]))) "test.c":7:10 -1
>      (expr_list:REG_DEAD (reg:DI 105)
>         (nil)))
> during RTL pass: ira
> 
> I think we need to check memory_operand in ix86_ternlog_idx
> 
>     case MEM:
>       if (MEM_P (op)
>   && MEM_VOLATILE_P (op)
>   && !volatile_ok)
> return -1;
>       /* FALLTHRU */
> 
> --
> BR,
> Hongtao

Comments

Hongtao Liu June 7, 2024, 6:20 a.m. UTC | #1
On Thu, Jun 6, 2024 at 6:07 PM Roger Sayle <roger@nextmovesoftware.com> wrote:
>
>
> Hi Hongtao,
> Here's the third revision of my improved ternlog handling patch for x86.
> This addresses the previously discovered problems, adding a check for
> memory_operand, and adds four new test cases, to confirm that the
> appropriate functionality is being triggered/covered, including a test
> case for the example you reported requiring the memory_operand fix.
> [Thanks to Alexander Monakov for suggesting I use my ternlog benchmark
> as a coverage testcase.]
>
> This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
> and make -k check, both with and without --target_board=unix{-m32}
> with no new failures.  Ok for mainline?
Ok.

BTW with -march=cascadelake, I notice there're new failures, most of
them can be fixed by adjusting ix86_rtx_cost(to recognize
ix86_ternlog_operand_p).

gcc: gcc.target/i386/avx2-pr98461.c scan-assembler-times \tnotl\t 6
gcc: gcc.target/i386/avx512f-copysign.c scan-assembler-times
vpternlog[dq][ \\t]+\\$(?:216|228|0xd8|0xe4), 5
gcc: gcc.target/i386/pr101989-broadcast-1.c scan-assembler-times \\{1to4\\} 4
gcc: gcc.target/i386/sse2-v1ti-vne.c scan-assembler-times pcmpeq 6
unix/-m32: gcc: gcc.target/i386/avx2-pr98461.c scan-assembler-times \tnotl\t 6
unix/-m32: gcc: gcc.target/i386/pr101989-broadcast-1.c
scan-assembler-times \\{1to4\\} 4


New tests that FAIL (6 tests):

gcc: gcc.target/i386/avx512f-vpternlogd-3.c scan-assembler-times
vpternlogd[ \\t] 694
gcc: gcc.target/i386/avx512f-vpternlogd-4.c scan-assembler-times
vpternlogd[ \\t] 694
unix/-m32: gcc: gcc.target/i386/avx512f-vpternlogd-3.c
scan-assembler-times vpternlogd[ \\t] 694
unix/-m32: gcc: gcc.target/i386/avx512f-vpternlogd-4.c
scan-assembler-times vpternlogd[ \\t] 694

>
>
> 2024-06-06  Roger Sayle  <roger@nextmovesoftware.com>
>             Hongtao Liu  <hongtao.liu@intel.com>
>
> gcc/ChangeLog
>         * config/i386/i386-expand.cc (ix86_expand_args_builtin): Call
>         fixup_modeless_constant before testing predicates.  Only call
>         copy_to_mode_reg on memory operands (after the first one).
>         (ix86_gen_bcst_mem): Helper function to convert a CONST_VECTOR
>         into a VEC_DUPLICATE if possible.
>         (ix86_ternlog_idx):  Convert an RTX expression into a ternlog
>         index between 0 and 255, recording the operands in ARGS, if
>         possible or return -1 if this is not possible/valid.
>         (ix86_ternlog_leaf_p): Helper function to identify "leaves"
>         of a ternlog expression, e.g. REG_P, MEM_P, CONST_VECTOR, etc.
>         (ix86_ternlog_operand_p): Test whether a expression is suitable
>         for and prefered as an UNSPEC_TERNLOG.
>         (ix86_expand_ternlog_binop): Helper function to construct the
>         binary operation corresponding to a sufficiently simple ternlog.
>         (ix86_expand_ternlog_andnot): Helper function to construct a
>         ANDN operation corresponding to a sufficiently simple ternlog.
>         (ix86_expand_ternlog): Expand a 3-operand ternary logic
>         expression, constructing either an UNSPEC_TERNLOG or simpler
>         rtx expression.  Called from builtin expanders and pre-reload
>         splitters.
>         * config/i386/i386-protos.h (ix86_ternlog_idx): Prototype here.
>         (ix86_ternlog_operand_p): Likewise.
>         (ix86_expand_ternlog): Likewise.
>         * config/i386/predicates.md (ternlog_operand): New predicate
>         that calls xi86_ternlog_operand_p.
>         * config/i386/sse.md (<avx512>_vpternlog<mode>_0): New
>         define_insn_and_split that recognizes a SET_SRC of ternlog_operand
>         and expands it via ix86_expand_ternlog pre-reload.
>         (<avx512>_vternlog<mode>_mask): Convert from define_insn to
>         define_expand.  Use ix86_expand_ternlog if the mask operand is
>         ~0 (or 255 or -1).
>         (*<avx512>_vternlog<mode>_mask): define_insn renamed from above.
>
> gcc/testsuite/ChangeLog
>         * gcc.target/i386/avx512f-vpternlogd-1.c: Update test case.
>         * gcc.target/i386/avx512f-vpternlogq-1.c: Likewise.
>         * gcc.target/i386/avx512vl-vpternlogd-1.c: Likewise.
>         * gcc.target/i386/avx512vl-vpternlogq-1.c: Likewise.
>         * gcc.target/i386/pr100711-4.c: Likewise.
>         * gcc.target/i386/pr100711-5.c: Likewise.
>
>         * gcc.target/i386/avx512f-vpternlogd-3.c: New 128-bit test case.
>         * gcc.target/i386/avx512f-vpternlogd-4.c: New 256-bit test case.
>         * gcc.target/i386/avx512f-vpternlogd-5.c: New 512-bit test case.
>         * gcc.target/i386/avx512f-vpternlogq-3.c: New test case.
>
>
> Thanks in advance,
> Roger
>
> > -----Original Message-----
> > From: Hongtao Liu <crazylht@gmail.com>
> > On Mon, May 27, 2024 at 2:48 PM Hongtao Liu <crazylht@gmail.com> wrote:
> > >
> > > On Sat, May 18, 2024 at 4:10 AM Roger Sayle <roger@nextmovesoftware.com>
> > wrote:
> > > >
> > > >
> > > > Hi Hongtao,
> > > > Many thanks for the review, bug fixes and suggestions for improvements.
> > > > This revised version of the patch, implements all of your
> > > > corrections.  In theory the "ternlog idx" should guarantee that some
> > > > operands are non-null, but I agree that it's better defensive programming to
> > check invariants not easily proved.
> > > > Instead of calling ix86_expand_vector_move, I use
> > > > ix86_broadcast_from_constant to achieve the same effect of using a
> > > > broadcast when possible, but has the benefit of still using a memory
> > > > operand (instead of a vector load) when broadcasting isn't possible.
> > > > There are other places that could benefit from the same trick, but I
> > > > can address these in a follow-up patch (it may even be preferrable
> > > > to keep these as CONST_VECTOR during early RTL passes and lower to
> > broadcast or constant pool using splitters).
> > > >
> > > > This revised patch has been tested on x86_64-pc-linux-gnu with make
> > > > bootstrap and make -k check, both with and without
> > > > --target_board=unix{-m32} with no new failures.  Ok for mainline?
> > > 1 file changed, 41 insertions(+)
> > > gcc/config/i386/i386-expand.cc | 41
> > > +++++++++++++++++++++++++++++++++++++++++
> > >
> > > modified   gcc/config/i386/i386-expand.cc
> > > @@ -25579,14 +25579,22 @@ ix86_gen_bcst_mem (machine_mode mode, rtx
> > x)
> > >        && !CONST_DOUBLE_P (cst)
> > >        && !CONST_FIXED_P (cst))
> > >      return NULL_RTX;
> > > +  /* I think VALID_BCST_MODE_P should be sufficient to
> > > +     make sure cst is CONST_INT or CONST_DOUBLE.  */
> > >
> > >    int n_elts = GET_MODE_NUNITS (mode);
> > >    if (CONST_VECTOR_NUNITS (x) != n_elts)
> > >      return NULL_RTX;
> > > +  /* Do we need this? I saw from caller side there's already
> > > +       if (GET_MODE (op2) != mode)
> > > + op2 = gen_lowpart (mode, op2);
> > > + tmp2 = ix86_gen_bcst_mem (mode, op2);  */
> > > +
> > >
> > >    for (int i = 1; i < n_elts; i++)
> > >      if (!rtx_equal_p (cst, CONST_VECTOR_ELT (x, i)))
> > >        return NULL_RTX;
> > > +  /* CONST_VECTOR_DUPLICATE_P (op)? */
> > >
> > >    rtx mem = force_const_mem (GET_MODE_INNER (mode), cst);
> > >    return gen_rtx_VEC_DUPLICATE (mode, validize_mem (mem)); @@
> > > -25709,6 +25717,21 @@ ix86_ternlog_idx (rtx op, rtx *args)
> > >     || ix86_ternlog_idx (XVECEXP (op, 0, 2), args) != 0xaa)
> > >   return -1;
> > >        return INTVAL (XVECEXP (op, 0, 3));
> > > +      /* I think we can add some testcase for this.
> > > + .i.e
> > > + #include <immintrin.h>
> > > +
> > > + __m256i
> > > + foo (__m256i a, __m256i b, __m256i c) { return (a &
> > > + _mm256_ternarylogic_epi64 (a, b, c, 0xe4)); }
> > > +
> > > + __m256i
> > > + foo1 (__m256i a, __m256i b, __m256i c) { return (b &
> > > + _mm256_ternarylogic_epi64 (a, b, c, 0xe4)); }  */
> > >
> > >      default:
> > >        return -1;
> > > @@ -25778,6 +25801,8 @@ ix86_ternlog_operand_p (rtx op)
> > >        if (ix86_ternlog_leaf_p (XEXP (op, 0), mode)
> > >     && (ix86_ternlog_leaf_p (op1, mode)
> > >         || vector_all_ones_operand (op1, mode)))
> > > + /* There's CONST_VECTOR check in x86_ternlog_leaf_p,
> > > +    so vector_all_ones_operand is not needed.  */
> > >   return false;
> > >        break;
> > >
> > > @@ -25862,6 +25887,10 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > > op0, rtx op1, rtx op2, int idx,
> > >        if ((!op0 || !side_effects_p (op0))
> > >            && (!op1 || !side_effects_p (op1))
> > >            && (!op2 || !side_effects_p (op2)))
> > > + /* I think only op2 needs to check side_effects_p, op0
> > > +    and op1 must be register operand when it exists, no need for
> > > side_effects_p?
> > > +    Similar for all below side_effects_p (op0/op1)
> > > +    the check is redundant.  */
> > >          {
> > >     emit_move_insn (target, CONST0_RTX (mode));
> > >     return target;
> > > @@ -25872,6 +25901,9 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > > op0, rtx op1, rtx op2, int idx,
> > >        if ((!op1 || !side_effects_p (op1))
> > >     && op0 && register_operand (op0, mode)
> > >     && op2 && register_operand (op2, mode))
> > > + /* op0/op1 must be register_operand when it exists,
> > > +    so register_operand (op0/op1, mode) is not needed.
> > > +    similar for all below register_operand (op0/op1, mode).  */
> > >   return ix86_expand_ternlog_andnot (mode, op0, op2, target);
> > >        break;
> > >
> > > @@ -25879,6 +25911,7 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > > op0, rtx op1, rtx op2, int idx,
> > >        if ((!op2 || !side_effects_p (op2))
> > >     && op0 && register_operand (op0, mode)
> > >     && op1 && register_operand (op1, mode))
> > > + /* op0 && op1? */
> > >   return ix86_expand_ternlog_andnot (mode, op0, op1, target);
> > >        break;
> > >
> > > @@ -25948,6 +25981,7 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > > op0, rtx op1, rtx op2, int idx,
> > >        if ((!op0 || !side_effects_p (op0))
> > >     && (!op1 || !side_effects_p (op1))
> > >            && op2)
> > > + /* if (op2).  */
> > >   {
> > >     if (GET_MODE (op2) != mode)
> > >       op2 = gen_lowpart (mode, op2);
> > > @@ -25961,18 +25995,21 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > > op0, rtx op1, rtx op2, int idx,
> > >      case 0x5a:  /* a^c */
> > >        if (op0 && op2
> > >            && (!op1 || !side_effects_p (op1)))
> > > + /* if (op0 && op2).  */
> > >   return ix86_expand_ternlog_binop (XOR, mode, op0, op2, target);
> > >        break;
> > >
> > >      case 0x66:  /* b^c */
> > >        if ((!op0 || !side_effects_p (op0))
> > >            && op1 && op2)
> > > + /* if (op1 && op2).  */
> > >   return ix86_expand_ternlog_binop (XOR, mode, op1, op2, target);
> > >        break;
> > >
> > >      case 0x88:  /* b&c */
> > >        if ((!op0 || !side_effects_p (op0))
> > >            && op1 && op2)
> > > + /* if (op1 && op2).  */
> > >   return ix86_expand_ternlog_binop (AND, mode, op1, op2, target);
> > >        break;
> > >
> > > @@ -26054,6 +26091,9 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > > op0, rtx op1, rtx op2, int idx,
> > >      }
> > >
> > >    tmp0 = register_operand (op0, mode) ? op0 : force_reg (mode, op0);
> > > +  /* Do you observe there're cases of op0 not register_operand?.
> > > +     if it's from <avx512>_vternlog<mode>_mask, it must be register_operand.
> > > +     if it's from ix86_ternlog_idx, it must REG_P.  */
> > >    if (GET_MODE (tmp0) != mode)
> > >      tmp0 = gen_lowpart (mode, tmp0);
> > >
> > > @@ -26061,6 +26101,7 @@ ix86_expand_ternlog (machine_mode mode, rtx
> > > op0, rtx op1, rtx op2, int idx,
> > >      tmp1 = copy_rtx (tmp0);
> > >    else if (!register_operand (op1, mode))
> > >      tmp1 = force_reg (mode, op1);
> > > +  /* Ditto.  */
> > >    else
> > >      tmp1 = op1;
> > >    if (GET_MODE (tmp1) != mode)
> > >
> > >
> > >
> > >
> > > --
> > > BR,
> > > Hongtao
> >
> > Got ICE for below testcase
> >
> > #include <immintrin.h>
> > __m256i
> > foo2 (__m256i** a, __m256i b)
> > {
> >   return ~(**a);
> > }
> >
> > with -march=x86-64-v4 -O2
> >
> >  (insn 17 7 13 2 (set (reg:V4DI 103 [ _5 ])
> >         (xor:V4DI (mem:V4DI (mem/f:DI (reg:DI 105) [1 *a_4(D)+0 S8
> > A64]) [0 *_1+0 S32 A256])
> >             (const_vector:V4DI [
> >                     (const_int -1 [0xffffffffffffffff]) repeated x4
> >                 ]))) "test.c":7:10 -1
> >      (expr_list:REG_DEAD (reg:DI 105)
> >         (nil)))
> > during RTL pass: ira
> >
> > I think we need to check memory_operand in ix86_ternlog_idx
> >
> >     case MEM:
> >       if (MEM_P (op)
> >   && MEM_VOLATILE_P (op)
> >   && !volatile_ok)
> > return -1;
> >       /* FALLTHRU */
> >
> > --
> > BR,
> > Hongtao
diff mbox series

Patch

diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index a613291..0eb9b20 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -11707,6 +11707,8 @@  ix86_expand_args_builtin (const struct builtin_description *d,
       tree arg = CALL_EXPR_ARG (exp, i);
       rtx op = expand_normal (arg);
       machine_mode mode = insn_p->operand[i + 1].mode;
+      /* Need to fixup modeless constant before testing predicate.  */
+      op = fixup_modeless_constant (op, mode);
       bool match = insn_p->operand[i + 1].predicate (op, mode);
 
       if (second_arg_count && i == 1)
@@ -11873,13 +11875,15 @@  ix86_expand_args_builtin (const struct builtin_description *d,
 	  /* If we aren't optimizing, only allow one memory operand to
 	     be generated.  */
 	  if (memory_operand (op, mode))
-	    num_memory++;
-
-	  op = fixup_modeless_constant (op, mode);
+	    {
+	      num_memory++;
+	      if (!optimize && num_memory > 1)
+		op = copy_to_mode_reg (mode, op);
+	    }
 
 	  if (GET_MODE (op) == mode || GET_MODE (op) == VOIDmode)
 	    {
-	      if (optimize || !match || num_memory > 1)
+	      if (!match)
 		op = copy_to_mode_reg (mode, op);
 	    }
 	  else
@@ -25480,4 +25484,550 @@  ix86_expand_fast_convert_bf_to_sf (rtx val)
   return ret;
 }
 
+/* Attempt to convert a CONST_VECTOR into a bcst_mem_operand.
+   Returns NULL_RTX if X is cannot be expressed as a suitable
+   VEC_DUPLICATE in mode MODE.  */
+
+static rtx
+ix86_gen_bcst_mem (machine_mode mode, rtx x)
+{
+  if (!TARGET_AVX512F
+      || GET_CODE (x) != CONST_VECTOR
+      || (!TARGET_AVX512VL
+	  && (GET_MODE_SIZE (mode) != 64 || !TARGET_EVEX512))
+      || !VALID_BCST_MODE_P (GET_MODE_INNER (mode))
+	 /* Disallow HFmode broadcast.  */
+      || GET_MODE_SIZE (GET_MODE_INNER (mode)) < 4)
+    return NULL_RTX;
+
+  rtx cst = CONST_VECTOR_ELT (x, 0);
+  if (!CONST_SCALAR_INT_P (cst)
+      && !CONST_DOUBLE_P (cst)
+      && !CONST_FIXED_P (cst))
+    return NULL_RTX;
+  
+  int n_elts = GET_MODE_NUNITS (mode);
+  if (CONST_VECTOR_NUNITS (x) != n_elts)
+    return NULL_RTX;
+
+  for (int i = 1; i < n_elts; i++)
+    if (!rtx_equal_p (cst, CONST_VECTOR_ELT (x, i)))
+      return NULL_RTX;
+
+  rtx mem = force_const_mem (GET_MODE_INNER (mode), cst);
+  return gen_rtx_VEC_DUPLICATE (mode, validize_mem (mem));
+}
+
+/* Determine the ternlog immediate index that implements 3-operand
+   ternary logic expression OP.  This uses and modifies the 3 element
+   array ARGS to record and check the leaves, either 3 REGs, or 2 REGs
+   and MEM.  Returns an index between 0 and 255 for a valid ternlog,
+   or -1 if the expression isn't suitable.  */
+
+int
+ix86_ternlog_idx (rtx op, rtx *args)
+{
+  int idx0, idx1;
+
+  if (!op)
+    return -1;
+
+  switch (GET_CODE (op))
+    {
+    case REG:
+      if (!args[0])
+	{
+	  args[0] = op;
+	  return 0xf0;
+	}
+      if (REGNO (op) == REGNO (args[0]))
+	return 0xf0;
+      if (!args[1])
+	{
+	  args[1] = op;
+	  return 0xcc;
+	}
+      if (REGNO (op) == REGNO (args[1]))
+	return 0xcc;
+      if (!args[2])
+	{
+	  args[2] = op;
+	  return 0xaa;
+	}
+      if (REG_P (args[2]) && REGNO (op) == REGNO (args[2]))
+	return 0xaa;
+      return -1;
+
+    case VEC_DUPLICATE:
+      if (!bcst_mem_operand (op, GET_MODE (op)))
+	return -1;
+      /* FALLTHRU */
+
+    case MEM:
+      if (!memory_operand (op, GET_MODE (op)))
+	return -1;
+      if (MEM_P (op)
+	  && MEM_VOLATILE_P (op)
+	  && !volatile_ok)
+	return -1;
+      /* FALLTHRU */
+
+    case CONST_VECTOR:
+      if (!args[2])
+	{
+	  args[2] = op;
+	  return 0xaa;
+	}
+      /* Maximum of one volatile memory reference per expression.  */
+      if (side_effects_p (op) && side_effects_p (args[2]))
+	return -1;
+      if (rtx_equal_p (op, args[2]))
+	return 0xaa;
+      /* Check if one CONST_VECTOR is the ones-complement of the other.  */
+      if (GET_CODE (op) == CONST_VECTOR
+	  && GET_CODE (args[2]) == CONST_VECTOR
+	  && rtx_equal_p (simplify_const_unary_operation (NOT, GET_MODE (op),
+							  op, GET_MODE (op)),
+			  args[2]))
+	return 0x55;
+      return -1;
+
+    case SUBREG:
+      if (GET_MODE_SIZE (GET_MODE (SUBREG_REG (op)))
+	  != GET_MODE_SIZE (GET_MODE (op)))
+	return -1;
+      return ix86_ternlog_idx (SUBREG_REG (op), args);
+
+    case NOT:
+      idx0 = ix86_ternlog_idx (XEXP (op, 0), args);
+      return (idx0 >= 0) ? idx0 ^ 0xff : -1;
+
+    case AND:
+      idx0 = ix86_ternlog_idx (XEXP (op, 0), args);
+      if (idx0 < 0)
+	return -1;
+      idx1 = ix86_ternlog_idx (XEXP (op, 1), args);
+      return (idx1 >= 0) ? idx0 & idx1 : -1;
+
+    case IOR:
+      idx0 = ix86_ternlog_idx (XEXP (op, 0), args);
+      if (idx0 < 0)
+	return -1;
+      idx1 = ix86_ternlog_idx (XEXP (op, 1), args);
+      return (idx1 >= 0) ? idx0 | idx1 : -1;
+
+    case XOR:
+      idx0 = ix86_ternlog_idx (XEXP (op, 0), args);
+      if (idx0 < 0)
+	return -1;
+      if (vector_all_ones_operand (XEXP (op, 1), GET_MODE (op)))
+	return idx0 ^ 0xff;
+      idx1 = ix86_ternlog_idx (XEXP (op, 1), args);
+      return (idx1 >= 0) ? idx0 ^ idx1 : -1;
+
+    case UNSPEC:
+      if (XINT (op, 1) != UNSPEC_VTERNLOG
+	  || XVECLEN (op, 0) != 4
+	  || !CONST_INT_P (XVECEXP (op, 0, 3)))
+	return -1;
+
+      /* TODO: Handle permuted operands.  */
+      if (ix86_ternlog_idx (XVECEXP (op, 0, 0), args) != 0xf0
+	  || ix86_ternlog_idx (XVECEXP (op, 0, 1), args) != 0xcc
+	  || ix86_ternlog_idx (XVECEXP (op, 0, 2), args) != 0xaa)
+	return -1;
+      return INTVAL (XVECEXP (op, 0, 3));
+
+    default:
+      return -1;
+    }
+}
+
+/* Return TRUE if OP (in mode MODE) is the leaf of a ternary logic
+   expression, such as a register or a memory reference.  */
+ 
+bool
+ix86_ternlog_leaf_p (rtx op, machine_mode mode)
+{
+  /* We can't use memory_operand here, as it may return a different
+     value before and after reload (for volatile MEMs) which creates
+     problems splitting instructions.  */
+  return register_operand (op, mode)
+	 || MEM_P (op)
+	 || GET_CODE (op) == CONST_VECTOR
+	 || bcst_mem_operand (op, mode);
+}
+
+/* Test whether OP is a 3-operand ternary logic expression suitable
+   for use in a ternlog instruction.  */
+
+bool
+ix86_ternlog_operand_p (rtx op)
+{
+  rtx op0, op1;
+  rtx args[3];
+
+  args[0] = NULL_RTX;
+  args[1] = NULL_RTX;
+  args[2] = NULL_RTX;
+  int idx = ix86_ternlog_idx (op, args);
+  if (idx < 0)
+    return false;
+
+  /* Don't match simple (binary or unary) expressions.  */
+  machine_mode mode = GET_MODE (op);
+  switch (GET_CODE (op))
+    {
+    case AND:
+      op0 = XEXP (op, 0);
+      op1 = XEXP (op, 1);
+
+      /* Prefer pand.  */
+      if (ix86_ternlog_leaf_p (op0, mode)
+	  && ix86_ternlog_leaf_p (op1, mode))
+	return false;
+      /* Prefer pandn.  */
+      if (GET_CODE (op0) == NOT
+	  && register_operand (XEXP (op0, 0), mode)
+	  && ix86_ternlog_leaf_p (op1, mode))
+	return false;
+      break;
+
+    case IOR:
+      /* Prefer por.  */
+      if (ix86_ternlog_leaf_p (XEXP (op, 0), mode)
+	  && ix86_ternlog_leaf_p (XEXP (op, 1), mode))
+	return false;
+      break;
+
+    case XOR:
+      op1 = XEXP (op, 1);
+      /* Prefer pxor, or one_cmpl<vmode>2.  */
+      if (ix86_ternlog_leaf_p (XEXP (op, 0), mode)
+	  && (ix86_ternlog_leaf_p (op1, mode)
+	      || vector_all_ones_operand (op1, mode)))
+	return false;
+      break;
+
+    default:
+      break;
+    }
+  return true;
+}
+
+/* Helper function for ix86_expand_ternlog.  */
+static rtx
+ix86_expand_ternlog_binop (enum rtx_code code, machine_mode mode,
+			   rtx op0, rtx op1, rtx target)
+{
+  if (GET_MODE (op0) != mode)
+    op0 = gen_lowpart (mode, op0);
+  if (GET_MODE (op1) != mode)
+    op1 = gen_lowpart (mode, op1);
+
+  if (GET_CODE (op0) == CONST_VECTOR)
+    op0 = validize_mem (force_const_mem (mode, op0));
+  if (GET_CODE (op1) == CONST_VECTOR)
+    op1 = validize_mem (force_const_mem (mode, op1));
+
+  if (memory_operand (op0, mode))
+    {
+      if (memory_operand (op1, mode))
+	op0 = force_reg (mode, op0);
+      else
+	std::swap (op0, op1);
+    }
+  rtx ops[3] = { target, op0, op1 };
+  ix86_expand_vector_logical_operator (code, mode, ops);
+  return target;
+}
+
+
+/* Helper function for ix86_expand_ternlog.  */
+static rtx
+ix86_expand_ternlog_andnot (machine_mode mode, rtx op0, rtx op1, rtx target)
+{
+  if (GET_MODE (op0) != mode)
+    op0 = gen_lowpart (mode, op0);
+  op0 = gen_rtx_NOT (mode, op0);
+  if (GET_MODE (op1) != mode)
+    op1 = gen_lowpart (mode, op1);
+  emit_move_insn (target, gen_rtx_AND (mode, op0, op1));
+  return target;
+}
+
+/* Expand a 3-operand ternary logic expression.  Return TARGET. */
+rtx
+ix86_expand_ternlog (machine_mode mode, rtx op0, rtx op1, rtx op2, int idx,
+		     rtx target)
+{
+  rtx tmp0, tmp1, tmp2;
+
+  if (!target)
+    target = gen_reg_rtx (mode);
+
+  /* Canonicalize ternlog index for degenerate (duplicated) operands.  */
+  if (rtx_equal_p (op0, op1) && rtx_equal_p (op0, op2))
+    switch (idx & 0x81)
+      {
+      case 0x00:
+	idx = 0x00;
+	break;
+      case 0x01:
+	idx = 0x0f;
+	break;
+      case 0x80:
+	idx = 0xf0;
+	break;
+      case 0x81:
+	idx = 0xff;
+	break;
+      }
+
+  switch (idx & 0xff)
+    {
+    case 0x00:
+      if ((!op0 || !side_effects_p (op0))
+          && (!op1 || !side_effects_p (op1))
+          && (!op2 || !side_effects_p (op2)))
+        {
+	  emit_move_insn (target, CONST0_RTX (mode));
+	  return target;
+	}
+      break;
+
+    case 0x0a: /* ~a&c */
+      if ((!op1 || !side_effects_p (op1))
+	  && op0 && register_operand (op0, mode)
+	  && op2 && register_operand (op2, mode))
+	return ix86_expand_ternlog_andnot (mode, op0, op2, target);
+      break;
+
+    case 0x0c: /* ~a&b */
+      if ((!op2 || !side_effects_p (op2))
+	  && op0 && register_operand (op0, mode)
+	  && op1 && register_operand (op1, mode))
+	return ix86_expand_ternlog_andnot (mode, op0, op1, target);
+      break;
+
+    case 0x0f:  /* ~a */
+      if ((!op1 || !side_effects_p (op1))
+	  && (!op2 || !side_effects_p (op2))
+          && op0)
+	{
+	  if (GET_MODE (op0) != mode)
+	    op0 = gen_lowpart (mode, op0);
+	  if (!TARGET_64BIT && !register_operand (op0, mode))
+	    op0 = force_reg (mode, op0);
+	  emit_move_insn (target, gen_rtx_XOR (mode, op0, CONSTM1_RTX (mode)));
+	  return target;
+	}
+      break;
+  
+    case 0x22: /* ~b&c */
+      if ((!op0 || !side_effects_p (op0))
+	  && op1 && register_operand (op1, mode)
+	  && op2 && register_operand (op2, mode))
+	return ix86_expand_ternlog_andnot (mode, op1, op2, target);
+      break;
+
+    case 0x30: /* ~b&a */
+      if ((!op2 || !side_effects_p (op2))
+	  && op0 && register_operand (op0, mode)
+	  && op1 && register_operand (op1, mode))
+	return ix86_expand_ternlog_andnot (mode, op1, op0, target);
+      break;
+
+    case 0x33:  /* ~b */
+      if ((!op0 || !side_effects_p (op0))
+	  && (!op2 || !side_effects_p (op2))
+          && op1)
+	{
+	  if (GET_MODE (op1) != mode)
+	    op1 = gen_lowpart (mode, op1);
+	  if (!TARGET_64BIT && !register_operand (op1, mode))
+	    op1 = force_reg (mode, op1);
+	  emit_move_insn (target, gen_rtx_XOR (mode, op1, CONSTM1_RTX (mode)));
+	  return target;
+	}
+      break;
+
+    case 0x3c:  /* a^b */
+      if (op0 && op1
+          && (!op2 || !side_effects_p (op2)))
+	return ix86_expand_ternlog_binop (XOR, mode, op0, op1, target);
+      break;
+
+    case 0x44: /* ~c&b */
+      if ((!op0 || !side_effects_p (op0))
+	  && op1 && register_operand (op1, mode)
+	  && op2 && register_operand (op2, mode))
+	return ix86_expand_ternlog_andnot (mode, op2, op1, target);
+      break;
+
+    case 0x50: /* ~c&a */
+      if ((!op1 || !side_effects_p (op1))
+	  && op0 && register_operand (op0, mode)
+	  && op2 && register_operand (op2, mode))
+	return ix86_expand_ternlog_andnot (mode, op2, op0, target);
+      break;
+
+    case 0x55:  /* ~c */
+      if ((!op0 || !side_effects_p (op0))
+	  && (!op1 || !side_effects_p (op1))
+          && op2)
+	{
+	  if (GET_MODE (op2) != mode)
+	    op2 = gen_lowpart (mode, op2);
+	  if (!TARGET_64BIT && !register_operand (op2, mode))
+	    op2 = force_reg (mode, op2);
+	  emit_move_insn (target, gen_rtx_XOR (mode, op2, CONSTM1_RTX (mode)));
+	  return target;
+	}
+      break;
+  
+    case 0x5a:  /* a^c */
+      if (op0 && op2
+          && (!op1 || !side_effects_p (op1)))
+	return ix86_expand_ternlog_binop (XOR, mode, op0, op2, target);
+      break;
+
+    case 0x66:  /* b^c */
+      if ((!op0 || !side_effects_p (op0))
+          && op1 && op2)
+	return ix86_expand_ternlog_binop (XOR, mode, op1, op2, target);
+      break;
+
+    case 0x88:  /* b&c */
+      if ((!op0 || !side_effects_p (op0))
+          && op1 && op2)
+	return ix86_expand_ternlog_binop (AND, mode, op1, op2, target);
+      break;
+
+    case 0xa0:  /* a&c */
+      if ((!op1 || !side_effects_p (op1))
+          && op0 && op2)
+	return ix86_expand_ternlog_binop (AND, mode, op0, op2, target);
+      break;
+
+    case 0xaa:  /* c */
+      if ((!op0 || !side_effects_p (op0))
+	  && (!op1 || !side_effects_p (op1))
+          && op2)
+	{
+	  if (GET_MODE (op2) != mode)
+	    op2 = gen_lowpart (mode, op2);
+	  emit_move_insn (target, op2);
+	  return target;
+	}
+      break;
+
+    case 0xc0:  /* a&b */
+      if (op0 && op1
+          && (!op2 || !side_effects_p (op2)))
+	return ix86_expand_ternlog_binop (AND, mode, op0, op1, target);
+      break;
+
+    case 0xcc:  /* b */
+      if ((!op0 || !side_effects_p (op0))
+          && op1
+	  && (!op2 || !side_effects_p (op2)))
+	{
+	  if (GET_MODE (op1) != mode)
+	    op1 = gen_lowpart (mode, op1);
+	  emit_move_insn (target, op1);
+	  return target;
+	}
+      break;
+
+    case 0xee:  /* b|c */
+      if ((!op0 || !side_effects_p (op0))
+          && op1 && op2)
+	return ix86_expand_ternlog_binop (IOR, mode, op1, op2, target);
+      break;
+
+    case 0xf0:  /* a */
+      if (op0
+          && (!op1 || !side_effects_p (op1))
+	  && (!op2 || !side_effects_p (op2)))
+	{
+	  if (GET_MODE (op0) != mode)
+	    op0 = gen_lowpart (mode, op0);
+	  emit_move_insn (target, op0);
+	  return target;
+	}
+      break;
+
+    case 0xfa:  /* a|c */
+      if (op0 && op2
+          && (!op1 || !side_effects_p (op1)))
+	return ix86_expand_ternlog_binop (IOR, mode, op0, op2, target);
+      break;
+
+    case 0xfc:  /* a|b */
+      if (op0 && op1
+          && (!op2 || !side_effects_p (op2)))
+	return ix86_expand_ternlog_binop (IOR, mode, op0, op1, target);
+      break;
+
+    case 0xff:
+      if ((!op0 || !side_effects_p (op0))
+          && (!op1 || !side_effects_p (op1))
+          && (!op2 || !side_effects_p (op2)))
+        {
+          emit_move_insn (target, CONSTM1_RTX (mode));
+	  return target;
+	}
+      break;
+    }
+
+  tmp0 = register_operand (op0, mode) ? op0 : force_reg (mode, op0);
+  if (GET_MODE (tmp0) != mode)
+    tmp0 = gen_lowpart (mode, tmp0);
+
+  if (!op1 || rtx_equal_p (op0, op1))
+    tmp1 = copy_rtx (tmp0);
+  else if (!register_operand (op1, mode))
+    tmp1 = force_reg (mode, op1);
+  else
+    tmp1 = op1;
+  if (GET_MODE (tmp1) != mode)
+    tmp1 = gen_lowpart (mode, tmp1);
+
+  if (!op2 || rtx_equal_p (op0, op2))
+    tmp2 = copy_rtx (tmp0);
+  else if (rtx_equal_p (op1, op2))
+    tmp2 = copy_rtx (tmp1);
+  else if (GET_CODE (op2) == CONST_VECTOR)
+    {
+      if (GET_MODE (op2) != mode)
+	op2 = gen_lowpart (mode, op2);
+      tmp2 = ix86_gen_bcst_mem (mode, op2);
+      if (!tmp2)
+	{
+	  tmp2 = validize_mem (force_const_mem (mode, op2));
+	  rtx bcast = ix86_broadcast_from_constant (mode, tmp2);
+	  if (bcast)
+	    {
+	      rtx reg2 = gen_reg_rtx (mode);
+	      bool ok = ix86_expand_vector_init_duplicate (false, mode,
+							   reg2, bcast);
+	      if (ok)
+		tmp2 = reg2;
+	    }
+	}
+    }
+  else
+    tmp2 = op2;
+  if (GET_MODE (tmp2) != mode)
+    tmp2 = gen_lowpart (mode, tmp2);
+  /* Some memory_operands are not vector_memory_operands.  */
+  if (!bcst_vector_operand (tmp2, mode))
+    tmp2 = force_reg (mode, tmp2);
+
+  rtvec vec = gen_rtvec (4, tmp0, tmp1, tmp2, GEN_INT (idx));
+  emit_move_insn (target, gen_rtx_UNSPEC (mode, vec, UNSPEC_VTERNLOG));
+  return target;
+}
+
 #include "gt-i386-expand.h"
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index 46214a6..9a3e183 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -245,6 +245,11 @@  extern rtx ix86_expand_fast_convert_bf_to_sf (rtx);
 extern rtx ix86_memtag_untagged_pointer (rtx, rtx);
 extern bool ix86_memtag_can_tag_addresses (void);
 
+extern int ix86_ternlog_idx (rtx op, rtx *args);
+extern bool ix86_ternlog_operand_p (rtx op);
+extern rtx ix86_expand_ternlog (machine_mode mode, rtx op0, rtx op1, rtx op2,
+				int idx, rtx target);
+
 #ifdef TREE_CODE
 extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree, int);
 #endif	/* TREE_CODE  */
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index 2a97776..7afe310 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -1098,6 +1098,11 @@ 
        (and (match_code "not")
 	    (match_test "nonimmediate_operand (XEXP (op, 0), mode)"))))
 
+;; True for expressions valid for 3-operand ternlog instructions.
+(define_predicate "ternlog_operand"
+  (and (match_code "not,and,ior,xor")
+       (match_test "ix86_ternlog_operand_p (op)")))
+
 ;; True if OP is acceptable as operand of DImode shift expander.
 (define_predicate "shiftdi_operand"
   (if_then_else (match_test "TARGET_64BIT")
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index 1bf5072..3148651 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -12940,6 +12940,26 @@ 
 ;;
 ;; and so on.
 
+(define_insn_and_split "*<avx512>_vpternlog<mode>_0"
+  [(set (match_operand:V 0 "register_operand")
+	(match_operand:V 1 "ternlog_operand"))]
+  "(<MODE_SIZE> == 64 || TARGET_AVX512VL
+    || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256))
+   && ix86_pre_reload_split ()"
+  "#"
+  "&& 1"
+  [(const_int 0)]
+{
+  rtx args[3];
+  args[0] = NULL_RTX;
+  args[1] = NULL_RTX;
+  args[2] = NULL_RTX;
+  int idx = ix86_ternlog_idx (operands[1], args);
+  ix86_expand_ternlog (<MODE>mode, args[0], args[1], args[2], idx,
+		       operands[0]);
+  DONE;
+})
+
 (define_code_iterator any_logic1 [and ior xor])
 (define_code_iterator any_logic2 [and ior xor])
 (define_code_attr logic_op [(and "&") (ior "|") (xor "^")])
@@ -13160,7 +13180,33 @@ 
 })
 
 
-(define_insn "<avx512>_vternlog<mode>_mask"
+(define_expand "<avx512>_vternlog<mode>_mask"
+  [(set (match_operand:VI48_AVX512VL 0 "register_operand")
+	(vec_merge:VI48_AVX512VL
+	  (unspec:VI48_AVX512VL
+	    [(match_operand:VI48_AVX512VL 1 "register_operand")
+	     (match_operand:VI48_AVX512VL 2 "register_operand")
+	     (match_operand:VI48_AVX512VL 3 "bcst_vector_operand")
+	     (match_operand:SI 4 "const_0_to_255_operand")]
+	    UNSPEC_VTERNLOG)
+	  (match_dup 1)
+	  (match_operand:<avx512fmaskmode> 5 "general_operand")))]
+  "TARGET_AVX512F"
+{
+  unsigned HOST_WIDE_INT mode_mask = GET_MODE_MASK (<avx512fmaskmode>mode);
+  if (CONST_INT_P (operands[5])
+      && (UINTVAL (operands[5]) & mode_mask) == mode_mask)
+    {
+      ix86_expand_ternlog (<MODE>mode, operands[1], operands[2],
+			   operands[3], INTVAL (operands[4]),
+			   operands[0]);
+      DONE;
+    }
+  if (!register_operand (operands[5], <avx512fmaskmode>mode))
+    operands[5] = force_reg (<avx512fmaskmode>mode, operands[5]);
+})
+
+(define_insn "*<avx512>_vternlog<mode>_mask"
   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
 	(vec_merge:VI48_AVX512VL
 	  (unspec:VI48_AVX512VL
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-1.c
index a88153a..b098487 100644
--- a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-1.c
@@ -1,6 +1,5 @@ 
 /* { dg-do compile } */
 /* { dg-options "-mavx512f -O2" } */
-/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
 /* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
 
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-3.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-3.c
new file mode 100644
index 0000000..fc66a9f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-3.c
@@ -0,0 +1,955 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx512f" } */
+
+typedef unsigned int V __attribute__ ((__vector_size__ (16)));
+
+V foo_0_1(V a, V b, V c) { return (V){0,0,0,0}; }
+
+V foo_1_1(V a, V b, V c) { return ~((b|a)|c); }
+
+V foo_2_1(V a, V b, V c) { return (~(b|a))&c; }
+
+V foo_3_1(V a, V b, V c) { return ~(b|a); }
+
+V foo_4_1(V a, V b, V c) { return (~(c|a))&b; }
+
+V foo_5_1(V a, V b, V c) { return ~(c|a); }
+
+V foo_6_1(V a, V b, V c) { return (c^b)&~a; }
+
+V foo_7_1(V a, V b, V c) { return ~((c&b)|a); }
+
+V foo_8_1(V a, V b, V c) { return (~a&c)&b; }
+V foo_8_2(V a, V b, V c) { return (~a&b)&c; }
+V foo_8_3(V a, V b, V c) { return (c&b)&~a; }
+
+V foo_9_1(V a, V b, V c) { return ~((c^b)|a); }
+
+V foo_10_1(V a, V b, V c) { return ~a&c; }
+
+V foo_11_1(V a, V b, V c) { return ~((~c&b)|a); }
+V foo_11_2(V a, V b, V c) { return (~b|c)&~a; }
+
+V foo_12_1(V a, V b, V c) { return ~a&b; }
+
+V foo_13_1(V a, V b, V c) { return ~((~b&c)|a); }
+V foo_13_2(V a, V b, V c) { return (~c|b)&~a; }
+
+V foo_14_1(V a, V b, V c) { return (c|b)&~a; }
+
+V foo_15_1(V a, V b, V c) { return ~a; }
+
+V foo_16_1(V a, V b, V c) { return (~(c|b))&a; }
+
+V foo_17_1(V a, V b, V c) { return ~(c|b); }
+
+V foo_18_1(V a, V b, V c) { return (c^a)&~b; }
+
+V foo_19_1(V a, V b, V c) { return ~((c&a)|b); }
+
+V foo_20_1(V a, V b, V c) { return (b^a)&~c; }
+
+V foo_21_1(V a, V b, V c) { return ~((b&a)|c); }
+
+V foo_22_1(V a, V b, V c) { return ((b^a)|(c&b))^c; }
+V foo_22_2(V a, V b, V c) { return ((c^a)|(c&b))^b; }
+V foo_22_3(V a, V b, V c) { return ((c^b)|(c&a))^a; }
+V foo_22_4(V a, V b, V c) { return ((b&a)|c)^(b|a); }
+V foo_22_5(V a, V b, V c) { return ((c&a)|b)^(c|a); }
+V foo_22_6(V a, V b, V c) { return ((c&b)|a)^(c|b); }
+
+V foo_23_1(V a, V b, V c) { return ~(((b^a)&(c^a))^a); }
+V foo_23_2(V a, V b, V c) { return ((b^a)&(c^a))^~a; }
+V foo_23_3(V a, V b, V c) { return ((b^a)&(c^b))^~b; }
+V foo_23_4(V a, V b, V c) { return ((b^a)&c)^(~(b&a)); }
+V foo_23_5(V a, V b, V c) { return ((c^a)&(c^b))^~c; }
+V foo_23_6(V a, V b, V c) { return ((c^a)&b)^(~(c&a)); }
+V foo_23_7(V a, V b, V c) { return ((c^b)&a)^(~(c&b)); }
+V foo_23_8(V a, V b, V c) { return (~((c^b)&a))^(c&b); }
+V foo_23_9(V a, V b, V c) { return (~((c^a)&b))^(c&a); }
+V foo_23_10(V a, V b, V c) { return (~((c^a)&(c^b)))^c; }
+V foo_23_11(V a, V b, V c) { return (~((b^a)&c))^(b&a); }
+V foo_23_12(V a, V b, V c) { return (~((b^a)&(c^b)))^b; }
+V foo_23_13(V a, V b, V c) { return (~((b^a)&(c^a)))^a; }
+V foo_23_14(V a, V b, V c) { return ((~(b^a))|c)^(b|a); }
+V foo_23_15(V a, V b, V c) { return ((~(c^a))|b)^(c|a); }
+V foo_23_16(V a, V b, V c) { return ((~(c^b))|a)^(c|b); }
+
+V foo_24_1(V a, V b, V c) { return (b^a)&(c^a); }
+
+V foo_25_1(V a, V b, V c) { return ~((c^b)|(c&a)); }
+V foo_25_2(V a, V b, V c) { return ((c&a)|~b)^c; }
+V foo_25_3(V a, V b, V c) { return ((b&a)|~c)^b; }
+
+V foo_26_1(V a, V b, V c) { return ((b&a)|c)^a; }
+
+V foo_27_1(V a, V b, V c) { return ~(((b^a)&c)^b); }
+V foo_27_2(V a, V b, V c) { return ((b^a)&c)^~b; }
+V foo_27_3(V a, V b, V c) { return (~b|c)^(c&a); }
+V foo_27_4(V a, V b, V c) { return (~((b^a)&c))^b; }
+V foo_27_5(V a, V b, V c) { return ((~(b^a))|c)^a; }
+V foo_27_6(V a, V b, V c) { return (~c|a)^(c|b); }
+
+V foo_28_1(V a, V b, V c) { return ((c&a)|b)^a; }
+
+V foo_29_1(V a, V b, V c) { return ~(((c^a)&b)^c); }
+V foo_29_2(V a, V b, V c) { return ((c^a)&b)^~c; }
+V foo_29_3(V a, V b, V c) { return (~((c^a)&b))^c; }
+V foo_29_4(V a, V b, V c) { return (~c|b)^(b&a); }
+V foo_29_5(V a, V b, V c) { return ((~(c^a))|b)^a; }
+V foo_29_6(V a, V b, V c) { return (~b|a)^(c|b); }
+
+V foo_30_1(V a, V b, V c) { return (c|b)^a; }
+
+V foo_31_1(V a, V b, V c) { return ~((c|b)&a); }
+
+V foo_32_1(V a, V b, V c) { return (~b&c)&a; }
+V foo_32_2(V a, V b, V c) { return (~b&a)&c; }
+V foo_32_3(V a, V b, V c) { return (c&a)&~b; }
+
+V foo_33_1(V a, V b, V c) { return ~((c^a)|b); }
+
+V foo_34_1(V a, V b, V c) { return ~b&c; }
+
+V foo_35_1(V a, V b, V c) { return ~((~c&a)|b); }
+V foo_35_2(V a, V b, V c) { return (~a|c)&~b; }
+
+V foo_36_1(V a, V b, V c) { return (b^a)&(c^b); }
+
+V foo_37_1(V a, V b, V c) { return ~((c^a)|(c&b)); }
+V foo_37_2(V a, V b, V c) { return ((c&b)|~a)^c; }
+V foo_37_3(V a, V b, V c) { return ((b&a)|~c)^a; }
+
+V foo_38_1(V a, V b, V c) { return ((b&a)|c)^b; }
+
+V foo_39_1(V a, V b, V c) { return ~(((b^a)&c)^a); }
+V foo_39_2(V a, V b, V c) { return ((b^a)&c)^~a; }
+V foo_39_3(V a, V b, V c) { return (~a|c)^(c&b); }
+V foo_39_4(V a, V b, V c) { return ((~(b^a))|c)^b; }
+V foo_39_5(V a, V b, V c) { return (~((b^a)&c))^a; }
+V foo_39_6(V a, V b, V c) { return (~c|b)^(c|a); }
+
+V foo_40_1(V a, V b, V c) { return (b^a)&c; }
+
+V foo_41_1(V a, V b, V c) { return ~((((b&a)|c)^a)^b); }
+V foo_41_2(V a, V b, V c) { return (((b&a)|c)^b)^~a; }
+V foo_41_3(V a, V b, V c) { return (~((b&a)|c))^(b^a); }
+V foo_41_4(V a, V b, V c) { return (((b&a)|c)^a)^~b; }
+V foo_41_5(V a, V b, V c) { return ((b&a)|c)^(~(b^a)); }
+V foo_41_6(V a, V b, V c) { return (~(((b&a)|c)^a))^b; }
+V foo_41_7(V a, V b, V c) { return ((b&a)|~c)^(b|a); }
+V foo_41_8(V a, V b, V c) { return (~(((b&a)|c)^b))^a; }
+
+V foo_42_1(V a, V b, V c) { return (~(b&a))&c; }
+
+V foo_43_1(V a, V b, V c) { return ~(((b^a)&(c^a))^b); }
+V foo_43_2(V a, V b, V c) { return ((b^a)&c)|(~(b|a)); }
+V foo_43_3(V a, V b, V c) { return ((b^a)&c)^(~(b|a)); }
+V foo_43_4(V a, V b, V c) { return ((b^a)&(c^b))^~a; }
+V foo_43_5(V a, V b, V c) { return ((b^a)&(c^a))^~b; }
+V foo_43_6(V a, V b, V c) { return ((b^a)|(c^a))^~c; }
+V foo_43_7(V a, V b, V c) { return (~((b^a)|(c^a)))^c; }
+V foo_43_8(V a, V b, V c) { return ((~(b^a))|c)^(b&a); }
+V foo_43_9(V a, V b, V c) { return (~((b^a)&(c^a)))^b; }
+V foo_43_10(V a, V b, V c) { return (~((b^a)&c))^(b|a); }
+V foo_43_11(V a, V b, V c) { return (~((b^a)&(c^b)))^a; }
+V foo_43_12(V a, V b, V c) { return ((c^b)|a)^(~c|b); }
+V foo_43_13(V a, V b, V c) { return ((c^a)|b)^(~c|a); }
+
+V foo_44_1(V a, V b, V c) { return (b^a)&(c|b); }
+V foo_44_2(V a, V b, V c) { return ((c|b)&a)^b; }
+
+V foo_45_1(V a, V b, V c) { return (~c|b)^a; }
+
+V foo_46_1(V a, V b, V c) { return (b&a)^(c|b); }
+V foo_46_2(V a, V b, V c) { return ((c^a)|b)^a; }
+
+V foo_47_1(V a, V b, V c) { return ~((~c|b)&a); }
+V foo_47_2(V a, V b, V c) { return (~b&c)|~a; }
+
+V foo_48_1(V a, V b, V c) { return ~b&a; }
+
+V foo_49_1(V a, V b, V c) { return ~((~a&c)|b); }
+V foo_49_2(V a, V b, V c) { return (~c|a)&~b; }
+
+V foo_50_1(V a, V b, V c) { return (c|a)&~b; }
+
+V foo_51_1(V a, V b, V c) { return ~b; }
+
+V foo_52_1(V a, V b, V c) { return ((c&b)|a)^b; }
+
+V foo_53_1(V a, V b, V c) { return ~(((c^b)&a)^c); }
+V foo_53_2(V a, V b, V c) { return ((c^b)&a)^~c; }
+V foo_53_3(V a, V b, V c) { return (~((c^b)&a))^c; }
+V foo_53_4(V a, V b, V c) { return (~c|a)^(b&a); }
+V foo_53_5(V a, V b, V c) { return ((~(c^b))|a)^b; }
+V foo_53_6(V a, V b, V c) { return (~a|b)^(c|a); }
+
+V foo_54_1(V a, V b, V c) { return (c|a)^b; }
+
+V foo_55_1(V a, V b, V c) { return ~((c|a)&b); }
+
+V foo_56_1(V a, V b, V c) { return (b^a)&(c|a); }
+V foo_56_2(V a, V b, V c) { return ((c|a)&b)^a; }
+
+V foo_57_1(V a, V b, V c) { return (~c|a)^b; }
+
+V foo_58_1(V a, V b, V c) { return (b&a)^(c|a); }
+V foo_58_2(V a, V b, V c) { return ((c^b)|a)^b; }
+
+V foo_59_1(V a, V b, V c) { return ~((~c|a)&b); }
+V foo_59_2(V a, V b, V c) { return (~a&c)|~b; }
+
+V foo_60_1(V a, V b, V c) { return b^a; }
+
+V foo_61_1(V a, V b, V c) { return (~(c|a))|(b^a); }
+V foo_61_2(V a, V b, V c) { return (~(c|b))|(b^a); }
+V foo_61_3(V a, V b, V c) { return ((~(c|b))|a)^b; }
+V foo_61_4(V a, V b, V c) { return ((~(c|a))|b)^a; }
+
+V foo_62_1(V a, V b, V c) { return (~a&c)|(b^a); }
+V foo_62_2(V a, V b, V c) { return (~b&c)|(b^a); }
+V foo_62_3(V a, V b, V c) { return ((~b&c)|a)^b; }
+V foo_62_4(V a, V b, V c) { return ((~a&c)|b)^a; }
+
+V foo_63_1(V a, V b, V c) { return ~(b&a); }
+
+V foo_64_1(V a, V b, V c) { return (~c&b)&a; }
+V foo_64_2(V a, V b, V c) { return (~c&a)&b; }
+V foo_64_3(V a, V b, V c) { return (b&a)&~c; }
+
+V foo_65_1(V a, V b, V c) { return ~((b^a)|c); }
+
+V foo_66_1(V a, V b, V c) { return (c^a)&(c^b); }
+
+V foo_67_1(V a, V b, V c) { return ~((b^a)|(c&b)); }
+V foo_67_2(V a, V b, V c) { return ((c&b)|~a)^b; }
+V foo_67_3(V a, V b, V c) { return ((c&a)|~b)^a; }
+
+V foo_68_1(V a, V b, V c) { return ~c&b; }
+
+V foo_69_1(V a, V b, V c) { return ~((~b&a)|c); }
+V foo_69_2(V a, V b, V c) { return (~a|b)&~c; }
+
+V foo_70_1(V a, V b, V c) { return ((c&a)|b)^c; }
+
+V foo_71_1(V a, V b, V c) { return ~(((c^a)&b)^a); }
+V foo_71_2(V a, V b, V c) { return ((c^a)&b)^~a; }
+V foo_71_3(V a, V b, V c) { return (~a|b)^(c&b); }
+V foo_71_4(V a, V b, V c) { return ((~(c^a))|b)^c; }
+V foo_71_5(V a, V b, V c) { return (~((c^a)&b))^a; }
+V foo_71_6(V a, V b, V c) { return (~b|c)^(b|a); }
+
+V foo_72_1(V a, V b, V c) { return (c^a)&b; }
+
+V foo_73_1(V a, V b, V c) { return ~((((c&a)|b)^a)^c); }
+V foo_73_2(V a, V b, V c) { return (((c&a)|b)^c)^~a; }
+V foo_73_3(V a, V b, V c) { return (~((c&a)|b))^(c^a); }
+V foo_73_4(V a, V b, V c) { return (((c&a)|b)^a)^~c; }
+V foo_73_5(V a, V b, V c) { return ((c&a)|b)^(~(c^a)); }
+V foo_73_6(V a, V b, V c) { return (~(((c&a)|b)^a))^c; }
+V foo_73_7(V a, V b, V c) { return ((c&a)|~b)^(c|a); }
+V foo_73_8(V a, V b, V c) { return (~(((c&a)|b)^c))^a; }
+
+V foo_74_1(V a, V b, V c) { return (c^a)&(c|b); }
+V foo_74_2(V a, V b, V c) { return ((c|b)&a)^c; }
+
+V foo_75_1(V a, V b, V c) { return (~b|c)^a; }
+
+V foo_76_1(V a, V b, V c) { return (~(c&a))&b; }
+
+V foo_77_1(V a, V b, V c) { return ~(((b^a)&(c^a))^c); }
+V foo_77_2(V a, V b, V c) { return ((c^a)&b)|(~(c|a)); }
+V foo_77_3(V a, V b, V c) { return ((c^a)&b)^(~(c|a)); }
+V foo_77_4(V a, V b, V c) { return ((c^a)&(c^b))^~a; }
+V foo_77_5(V a, V b, V c) { return ((b^a)&(c^a))^~c; }
+V foo_77_6(V a, V b, V c) { return ((b^a)|(c^a))^~b; }
+V foo_77_7(V a, V b, V c) { return (~((b^a)|(c^a)))^b; }
+V foo_77_8(V a, V b, V c) { return ((~(c^a))|b)^(c&a); }
+V foo_77_9(V a, V b, V c) { return (~((b^a)&(c^a)))^c; }
+V foo_77_10(V a, V b, V c) { return (~((c^a)&b))^(c|a); }
+V foo_77_11(V a, V b, V c) { return ((c^b)|a)^(~b|c); }
+V foo_77_12(V a, V b, V c) { return (~((c^a)&(c^b)))^a; }
+V foo_77_13(V a, V b, V c) { return ((b^a)|c)^(~b|a); }
+
+V foo_78_1(V a, V b, V c) { return (c&a)^(c|b); }
+V foo_78_2(V a, V b, V c) { return ((b^a)|c)^a; }
+
+V foo_79_1(V a, V b, V c) { return ~((~b|c)&a); }
+V foo_79_2(V a, V b, V c) { return (~c&b)|~a; }
+
+V foo_80_1(V a, V b, V c) { return ~c&a; }
+
+V foo_81_1(V a, V b, V c) { return ~((~a&b)|c); }
+V foo_81_2(V a, V b, V c) { return (~b|a)&~c; }
+
+V foo_82_1(V a, V b, V c) { return ((c&b)|a)^c; }
+
+V foo_83_1(V a, V b, V c) { return ~(((c^b)&a)^b); }
+V foo_83_2(V a, V b, V c) { return ((c^b)&a)^~b; }
+V foo_83_3(V a, V b, V c) { return (~((c^b)&a))^b; }
+V foo_83_4(V a, V b, V c) { return (~b|a)^(c&a); }
+V foo_83_5(V a, V b, V c) { return ((~(c^b))|a)^c; }
+V foo_83_6(V a, V b, V c) { return (~a|c)^(b|a); }
+
+V foo_84_1(V a, V b, V c) { return (b|a)&~c; }
+
+V foo_85_1(V a, V b, V c) { return ~c; }
+
+V foo_86_1(V a, V b, V c) { return (b|a)^c; }
+
+V foo_87_1(V a, V b, V c) { return ~((b|a)&c); }
+
+V foo_88_1(V a, V b, V c) { return (c^a)&(b|a); }
+V foo_88_2(V a, V b, V c) { return ((b|a)&c)^a; }
+
+V foo_89_1(V a, V b, V c) { return (~b|a)^c; }
+
+V foo_90_1(V a, V b, V c) { return c^a; }
+
+V foo_91_1(V a, V b, V c) { return (~(b|a))|(c^a); }
+V foo_91_2(V a, V b, V c) { return (~(c|b))|(c^a); }
+V foo_91_3(V a, V b, V c) { return ((~(c|b))|a)^c; }
+V foo_91_4(V a, V b, V c) { return ((~(b|a))|c)^a; }
+
+V foo_92_1(V a, V b, V c) { return (c&a)^(b|a); }
+V foo_92_2(V a, V b, V c) { return ((c^b)|a)^c; }
+
+V foo_93_1(V a, V b, V c) { return ~((~b|a)&c); }
+V foo_93_2(V a, V b, V c) { return (~a&b)|~c; }
+
+V foo_94_1(V a, V b, V c) { return (~a&b)|(c^a); }
+V foo_94_2(V a, V b, V c) { return (~c&b)|(c^a); }
+V foo_94_3(V a, V b, V c) { return ((~c&b)|a)^c; }
+V foo_94_4(V a, V b, V c) { return ((~a&b)|c)^a; }
+
+V foo_95_1(V a, V b, V c) { return ~(c&a); }
+
+V foo_96_1(V a, V b, V c) { return (c^b)&a; }
+
+V foo_97_1(V a, V b, V c) { return ~(((c|b)^a)|(c&b)); }
+V foo_97_2(V a, V b, V c) { return (~((c&b)|a))^(c^b); }
+V foo_97_3(V a, V b, V c) { return (((c&b)|a)^c)^~b; }
+V foo_97_4(V a, V b, V c) { return (((c&b)|a)^b)^~c; }
+V foo_97_5(V a, V b, V c) { return ((c&b)|~a)^(c|b); }
+V foo_97_6(V a, V b, V c) { return ((c&b)|a)^(~(c^b)); }
+V foo_97_7(V a, V b, V c) { return (~(((c&b)|a)^b))^c; }
+V foo_97_8(V a, V b, V c) { return (~(((c&b)|a)^c))^b; }
+
+V foo_98_1(V a, V b, V c) { return (c^b)&(c|a); }
+V foo_98_2(V a, V b, V c) { return ((c|a)&b)^c; }
+
+V foo_99_1(V a, V b, V c) { return (~a|c)^b; }
+
+V foo_100_1(V a, V b, V c) { return (c^b)&(b|a); }
+V foo_100_2(V a, V b, V c) { return ((b|a)&c)^b; }
+
+V foo_101_1(V a, V b, V c) { return (~a|b)^c; }
+
+V foo_102_1(V a, V b, V c) { return c^b; }
+
+V foo_103_1(V a, V b, V c) { return (~(b|a))|(c^b); }
+V foo_103_2(V a, V b, V c) { return (~(c|a))|(c^b); }
+V foo_103_3(V a, V b, V c) { return ((~(c|a))|b)^c; }
+V foo_103_4(V a, V b, V c) { return ((~(b|a))|c)^b; }
+
+V foo_104_1(V a, V b, V c) { return ((b&a)^c)&(b|a); }
+V foo_104_2(V a, V b, V c) { return ((c&a)^b)&(c|a); }
+V foo_104_3(V a, V b, V c) { return ((c&b)^a)&(c|b); }
+V foo_104_4(V a, V b, V c) { return ((c|b)&a)^(c&b); }
+V foo_104_5(V a, V b, V c) { return ((c|a)&b)^(c&a); }
+V foo_104_6(V a, V b, V c) { return ((b|a)&c)^(b&a); }
+
+V foo_105_1(V a, V b, V c) { return ~((b^a)^c); }
+V foo_105_2(V a, V b, V c) { return (c^b)^~a; }
+V foo_105_3(V a, V b, V c) { return (c^a)^~b; }
+V foo_105_4(V a, V b, V c) { return (b^a)^~c; }
+V foo_105_5(V a, V b, V c) { return (~(c^b))^a; }
+V foo_105_6(V a, V b, V c) { return (~(c^a))^b; }
+V foo_105_7(V a, V b, V c) { return (~(b^a))^c; }
+
+V foo_106_1(V a, V b, V c) { return (b&a)^c; }
+
+V foo_107_1(V a, V b, V c) { return ~(((b|a)&c)^(b^a)); }
+V foo_107_2(V a, V b, V c) { return ((b&a)^c)|(~(b|a)); }
+V foo_107_3(V a, V b, V c) { return ((c^b)&(b|a))^~a; }
+V foo_107_4(V a, V b, V c) { return ((c^a)&(b|a))^~b; }
+V foo_107_5(V a, V b, V c) { return (~((b|a)&c))^(b^a); }
+V foo_107_6(V a, V b, V c) { return (~((c^b)&(b|a)))^a; }
+V foo_107_7(V a, V b, V c) { return (~((c^a)&(b|a)))^b; }
+V foo_107_8(V a, V b, V c) { return ((b|a)&c)^(~(b^a)); }
+V foo_107_9(V a, V b, V c) { return ((~(b|a))|c)^(b&a); }
+
+V foo_108_1(V a, V b, V c) { return (c&a)^b; }
+
+V foo_109_1(V a, V b, V c) { return ~(((b^a)&(c|a))^c); }
+V foo_109_2(V a, V b, V c) { return ((c&a)^b)|(~(c|a)); }
+V foo_109_3(V a, V b, V c) { return ((c^b)&(c|a))^~a; }
+V foo_109_4(V a, V b, V c) { return (~((c|a)&b))^(c^a); }
+V foo_109_5(V a, V b, V c) { return ((b^a)&(c|a))^~c; }
+V foo_109_6(V a, V b, V c) { return (~((c^b)&(c|a)))^a; }
+V foo_109_7(V a, V b, V c) { return ((~(c|a))|b)^(c&a); }
+V foo_109_8(V a, V b, V c) { return ((c|a)&b)^(~(c^a)); }
+V foo_109_9(V a, V b, V c) { return (~((b^a)&(c|a)))^c; }
+
+V foo_110_1(V a, V b, V c) { return (~a&c)|(c^b); }
+V foo_110_2(V a, V b, V c) { return (~a&b)|(c^b); }
+V foo_110_3(V a, V b, V c) { return ((~b|a)&c)^b; }
+V foo_110_4(V a, V b, V c) { return ((~c|a)&b)^c; }
+
+V foo_111_1(V a, V b, V c) { return (c^b)|~a; }
+
+V foo_112_1(V a, V b, V c) { return (~(c&b))&a; }
+
+V foo_113_1(V a, V b, V c) { return ~(((b^a)&(c^b))^c); }
+V foo_113_2(V a, V b, V c) { return ((b^a)|(c^a))^~a; }
+V foo_113_3(V a, V b, V c) { return ((c^b)&a)|(~(c|b)); }
+V foo_113_4(V a, V b, V c) { return ((c^b)&a)^(~(c|b)); }
+V foo_113_5(V a, V b, V c) { return ((b^a)&(c^b))^~c; }
+V foo_113_6(V a, V b, V c) { return ((c^a)&(c^b))^~b; }
+V foo_113_7(V a, V b, V c) { return (~((b^a)|(c^a)))^a; }
+V foo_113_8(V a, V b, V c) { return ((~(c^b))|a)^(c&b); }
+V foo_113_9(V a, V b, V c) { return (~((c^b)&a))^(c|b); }
+V foo_113_10(V a, V b, V c) { return (~((b^a)&(c^b)))^c; }
+V foo_113_11(V a, V b, V c) { return ((c^a)|b)^(~a|c); }
+V foo_113_12(V a, V b, V c) { return (~((c^a)&(c^b)))^b; }
+V foo_113_13(V a, V b, V c) { return ((b^a)|c)^(~a|b); }
+
+V foo_114_1(V a, V b, V c) { return (c&b)^(c|a); }
+V foo_114_2(V a, V b, V c) { return ((b^a)|c)^b; }
+
+V foo_115_1(V a, V b, V c) { return ~((~a|c)&b); }
+V foo_115_2(V a, V b, V c) { return (~c&a)|~b; }
+
+V foo_116_1(V a, V b, V c) { return (c&b)^(b|a); }
+V foo_116_2(V a, V b, V c) { return ((c^a)|b)^c; }
+
+V foo_117_1(V a, V b, V c) { return ~((~a|b)&c); }
+V foo_117_2(V a, V b, V c) { return (~b&a)|~c; }
+
+V foo_118_1(V a, V b, V c) { return (~b&a)|(c^b); }
+V foo_118_2(V a, V b, V c) { return (~c&a)|(c^b); }
+V foo_118_3(V a, V b, V c) { return ((~c&a)|b)^c; }
+V foo_118_4(V a, V b, V c) { return ((~b&a)|c)^b; }
+
+V foo_119_1(V a, V b, V c) { return ~(c&b); }
+
+V foo_120_1(V a, V b, V c) { return (c&b)^a; }
+
+V foo_121_1(V a, V b, V c) { return ~(((b^a)&(c|b))^c); }
+V foo_121_2(V a, V b, V c) { return ((c&b)^a)|(~(c|b)); }
+V foo_121_3(V a, V b, V c) { return (~((c|b)&a))^(c^b); }
+V foo_121_4(V a, V b, V c) { return ((b^a)&(c|b))^~c; }
+V foo_121_5(V a, V b, V c) { return ((c^a)&(c|b))^~b; }
+V foo_121_6(V a, V b, V c) { return ((~(c|b))|a)^(c&b); }
+V foo_121_7(V a, V b, V c) { return ((c|b)&a)^(~(c^b)); }
+V foo_121_8(V a, V b, V c) { return (~((b^a)&(c|b)))^c; }
+V foo_121_9(V a, V b, V c) { return (~((c^a)&(c|b)))^b; }
+
+V foo_122_1(V a, V b, V c) { return (~b&c)|(c^a); }
+V foo_122_2(V a, V b, V c) { return (~b&a)|(c^a); }
+V foo_122_3(V a, V b, V c) { return ((~a|b)&c)^a; }
+V foo_122_4(V a, V b, V c) { return ((~c|b)&a)^c; }
+
+V foo_123_1(V a, V b, V c) { return (c^a)|~b; }
+
+V foo_124_1(V a, V b, V c) { return (~c&b)|(b^a); }
+V foo_124_2(V a, V b, V c) { return (~c&a)|(b^a); }
+V foo_124_3(V a, V b, V c) { return ((~a|c)&b)^a; }
+V foo_124_4(V a, V b, V c) { return ((~b|c)&a)^b; }
+
+V foo_125_1(V a, V b, V c) { return (b^a)|~c; }
+
+V foo_126_1(V a, V b, V c) { return (b^a)|(c^a); }
+V foo_126_2(V a, V b, V c) { return (b^a)|(c^b); }
+V foo_126_3(V a, V b, V c) { return (c^a)|(c^b); }
+
+V foo_127_1(V a, V b, V c) { return ~((c&b)&a); }
+
+V foo_128_1(V a, V b, V c) { return (c&b)&a; }
+V foo_128_2(V a, V b, V c) { return (c&a)&b; }
+V foo_128_3(V a, V b, V c) { return (b&a)&c; }
+
+V foo_129_1(V a, V b, V c) { return ~((b^a)|(c^a)); }
+
+V foo_130_1(V a, V b, V c) { return (~(b^a))&c; }
+
+V foo_131_1(V a, V b, V c) { return ~((~c&b)|(b^a)); }
+V foo_131_2(V a, V b, V c) { return ((~a|c)&b)^~a; }
+V foo_131_3(V a, V b, V c) { return ((~b|c)&a)^~b; }
+V foo_131_4(V a, V b, V c) { return (~((~b|c)&a))^b; }
+V foo_131_5(V a, V b, V c) { return (~((~a|c)&b))^a; }
+V foo_131_6(V a, V b, V c) { return (~a|c)&(~(b^a)); }
+V foo_131_7(V a, V b, V c) { return (~b|c)&(~(b^a)); }
+
+V foo_132_1(V a, V b, V c) { return (~(c^a))&b; }
+
+V foo_133_1(V a, V b, V c) { return ~((~b&c)|(c^a)); }
+V foo_133_2(V a, V b, V c) { return ((~a|b)&c)^~a; }
+V foo_133_3(V a, V b, V c) { return (~((~c|b)&a))^c; }
+V foo_133_4(V a, V b, V c) { return ((~c|b)&a)^~c; }
+V foo_133_5(V a, V b, V c) { return (~((~a|b)&c))^a; }
+V foo_133_6(V a, V b, V c) { return (~(c^a))&(~a|b); }
+V foo_133_7(V a, V b, V c) { return (~(c^a))&(~c|b); }
+
+V foo_134_1(V a, V b, V c) { return ((b^a)&(c|b))^c; }
+V foo_134_2(V a, V b, V c) { return ((c^a)&(c|b))^b; }
+V foo_134_3(V a, V b, V c) { return ((c|b)&a)^(c^b); }
+V foo_134_4(V a, V b, V c) { return ((b^a)^c)&(c|b); }
+
+V foo_135_1(V a, V b, V c) { return ~((c&b)^a); }
+V foo_135_2(V a, V b, V c) { return (c&b)^~a; }
+V foo_135_3(V a, V b, V c) { return (~(c&b))^a; }
+
+V foo_136_1(V a, V b, V c) { return c&b; }
+
+V foo_137_1(V a, V b, V c) { return ~((~b&a)|(c^b)); }
+V foo_137_2(V a, V b, V c) { return (~((~c&a)|b))^c; }
+V foo_137_3(V a, V b, V c) { return ((~b&a)|c)^~b; }
+V foo_137_4(V a, V b, V c) { return (~((~b&a)|c))^b; }
+V foo_137_5(V a, V b, V c) { return ((~c&a)|b)^~c; }
+V foo_137_6(V a, V b, V c) { return (~(c^b))&(~a|c); }
+V foo_137_7(V a, V b, V c) { return (~(c^b))&(~a|b); }
+
+V foo_138_1(V a, V b, V c) { return (~a|b)&c; }
+
+V foo_139_1(V a, V b, V c) { return ~((c&b)^(b|a)); }
+V foo_139_2(V a, V b, V c) { return (~(b|a))|(c&b); }
+V foo_139_3(V a, V b, V c) { return (~(b|a))^(c&b); }
+V foo_139_4(V a, V b, V c) { return (~((c^a)|b))^c; }
+V foo_139_5(V a, V b, V c) { return ((c^a)|b)^~c; }
+V foo_139_6(V a, V b, V c) { return (~(c&b))^(b|a); }
+V foo_139_7(V a, V b, V c) { return ((c^a)|~b)^a; }
+
+V foo_140_1(V a, V b, V c) { return (~a|c)&b; }
+
+V foo_141_1(V a, V b, V c) { return ~((c&b)^(c|a)); }
+V foo_141_2(V a, V b, V c) { return (~(c|a))|(c&b); }
+V foo_141_3(V a, V b, V c) { return (~(c|a))^(c&b); }
+V foo_141_4(V a, V b, V c) { return ((b^a)|c)^~b; }
+V foo_141_5(V a, V b, V c) { return (~((b^a)|c))^b; }
+V foo_141_6(V a, V b, V c) { return (~(c&b))^(c|a); }
+V foo_141_7(V a, V b, V c) { return ((b^a)|~c)^a; }
+
+V foo_142_1(V a, V b, V c) { return ((b^a)&(c^b))^c; }
+V foo_142_2(V a, V b, V c) { return ((c^a)&(c^b))^b; }
+V foo_142_3(V a, V b, V c) { return ((c^b)&a)^(c|b); }
+V foo_142_4(V a, V b, V c) { return ((b^a)|(c^a))^a; }
+
+V foo_143_1(V a, V b, V c) { return (c&b)|~a; }
+
+V foo_144_1(V a, V b, V c) { return (~(c^b))&a; }
+
+V foo_145_1(V a, V b, V c) { return ~((~a&c)|(c^b)); }
+V foo_145_2(V a, V b, V c) { return ((~b|a)&c)^~b; }
+V foo_145_3(V a, V b, V c) { return (~((~c|a)&b))^c; }
+V foo_145_4(V a, V b, V c) { return ((~c|a)&b)^~c; }
+V foo_145_5(V a, V b, V c) { return (~((~b|a)&c))^b; }
+V foo_145_6(V a, V b, V c) { return (~(c^b))&(~b|a); }
+V foo_145_7(V a, V b, V c) { return (~(c^b))&(~c|a); }
+
+V foo_146_1(V a, V b, V c) { return ((b^a)&(c|a))^c; }
+V foo_146_2(V a, V b, V c) { return ((c|a)&b)^(c^a); }
+V foo_146_3(V a, V b, V c) { return ((c^b)&(c|a))^a; }
+V foo_146_4(V a, V b, V c) { return ((b^a)^c)&(c|a); }
+
+V foo_147_1(V a, V b, V c) { return ~((c&a)^b); }
+V foo_147_2(V a, V b, V c) { return (c&a)^~b; }
+V foo_147_3(V a, V b, V c) { return (~(c&a))^b; }
+
+V foo_148_1(V a, V b, V c) { return ((b|a)&c)^(b^a); }
+V foo_148_2(V a, V b, V c) { return ((c^a)&(b|a))^b; }
+V foo_148_3(V a, V b, V c) { return ((c^b)&(b|a))^a; }
+V foo_148_4(V a, V b, V c) { return ((b^a)^c)&(b|a); }
+
+V foo_149_1(V a, V b, V c) { return ~((b&a)^c); }
+V foo_149_2(V a, V b, V c) { return (~(b&a))^c; }
+V foo_149_3(V a, V b, V c) { return (b&a)^~c; }
+
+V foo_150_1(V a, V b, V c) { return (b^a)^c; }
+V foo_150_2(V a, V b, V c) { return (c^a)^b; }
+V foo_150_3(V a, V b, V c) { return (c^b)^a; }
+
+V foo_151_1(V a, V b, V c) { return ~(((b&a)^c)&(b|a)); }
+V foo_151_2(V a, V b, V c) { return ((b^a)^c)|(~(b|a)); }
+V foo_151_3(V a, V b, V c) { return ((b^a)^c)|(~(c|a)); }
+V foo_151_4(V a, V b, V c) { return ((b^a)^c)|(~(c|b)); }
+V foo_151_5(V a, V b, V c) { return (~((c|b)&a))^(c&b); }
+V foo_151_6(V a, V b, V c) { return (~((c|a)&b))^(c&a); }
+V foo_151_7(V a, V b, V c) { return ((~(b|a))|c)^(b^a); }
+V foo_151_8(V a, V b, V c) { return ((~(c|a))|(b^a))^c; }
+V foo_151_9(V a, V b, V c) { return ((b|a)&c)^(~(b&a)); }
+V foo_151_10(V a, V b, V c) { return (~((b|a)&c))^(b&a); }
+V foo_151_11(V a, V b, V c) { return ((~(c|a))|b)^(c^a); }
+V foo_151_12(V a, V b, V c) { return ((~(b|a))|(c^a))^b; }
+V foo_151_13(V a, V b, V c) { return ((c|a)&b)^(~(c&a)); }
+V foo_151_14(V a, V b, V c) { return ((~(c|b))|a)^(c^b); }
+V foo_151_15(V a, V b, V c) { return ((~(b|a))|(c^b))^a; }
+V foo_151_16(V a, V b, V c) { return ((c|b)&a)^(~(c&b)); }
+
+V foo_152_1(V a, V b, V c) { return ((c|a)&~b)^c; }
+V foo_152_2(V a, V b, V c) { return ((b|a)&~c)^b; }
+V foo_152_3(V a, V b, V c) { return (~(c^b))&(c|a); }
+V foo_152_4(V a, V b, V c) { return (~(c^b))&(b|a); }
+
+V foo_153_1(V a, V b, V c) { return ~(c^b); }
+V foo_153_2(V a, V b, V c) { return ~b^c; }
+V foo_153_3(V a, V b, V c) { return ~c^b; }
+
+V foo_154_1(V a, V b, V c) { return (~b&a)^c; }
+
+V foo_155_1(V a, V b, V c) { return ~((c^b)&(b|a)); }
+V foo_155_2(V a, V b, V c) { return ((b|a)&c)^~b; }
+V foo_155_3(V a, V b, V c) { return (~((b|a)&c))^b; }
+
+V foo_156_1(V a, V b, V c) { return (~c&a)^b; }
+
+V foo_157_1(V a, V b, V c) { return ~((c^b)&(c|a)); }
+V foo_157_2(V a, V b, V c) { return (~((c|a)&b))^c; }
+V foo_157_3(V a, V b, V c) { return ((c|a)&b)^~c; }
+
+V foo_158_1(V a, V b, V c) { return ((c|b)^a)|(c&b); }
+V foo_158_2(V a, V b, V c) { return (((c&b)|a)^b)^c; }
+V foo_158_3(V a, V b, V c) { return (((c&b)|a)^c)^b; }
+V foo_158_4(V a, V b, V c) { return ((c&b)|a)^(c^b); }
+V foo_158_5(V a, V b, V c) { return ((b^a)^c)|(c&b); }
+
+V foo_159_1(V a, V b, V c) { return ~((c^b)&a); }
+
+V foo_160_1(V a, V b, V c) { return c&a; }
+
+V foo_161_1(V a, V b, V c) { return ~((~a&b)|(c^a)); }
+V foo_161_2(V a, V b, V c) { return (~((~c&b)|a))^c; }
+V foo_161_3(V a, V b, V c) { return ((~a&b)|c)^~a; }
+V foo_161_4(V a, V b, V c) { return (~((~a&b)|c))^a; }
+V foo_161_5(V a, V b, V c) { return ((~c&b)|a)^~c; }
+V foo_161_6(V a, V b, V c) { return (~(c^a))&(~b|c); }
+V foo_161_7(V a, V b, V c) { return (~(c^a))&(~b|a); }
+
+V foo_162_1(V a, V b, V c) { return (~b|a)&c; }
+
+V foo_163_1(V a, V b, V c) { return ~((c&a)^(b|a)); }
+V foo_163_2(V a, V b, V c) { return (~(b|a))|(c&a); }
+V foo_163_3(V a, V b, V c) { return (~(b|a))^(c&a); }
+V foo_163_4(V a, V b, V c) { return (~((c^b)|a))^c; }
+V foo_163_5(V a, V b, V c) { return ((c^b)|a)^~c; }
+V foo_163_6(V a, V b, V c) { return (~(c&a))^(b|a); }
+V foo_163_7(V a, V b, V c) { return ((c^b)|~a)^b; }
+
+V foo_164_1(V a, V b, V c) { return ((c|b)&~a)^c; }
+V foo_164_2(V a, V b, V c) { return ((b|a)&~c)^a; }
+V foo_164_3(V a, V b, V c) { return (~(c^a))&(c|b); }
+V foo_164_4(V a, V b, V c) { return (~(c^a))&(b|a); }
+
+V foo_165_1(V a, V b, V c) { return ~(c^a); }
+V foo_165_2(V a, V b, V c) { return ~a^c; }
+V foo_165_3(V a, V b, V c) { return ~c^a; }
+
+V foo_166_1(V a, V b, V c) { return (~a&b)^c; }
+
+V foo_167_1(V a, V b, V c) { return ~((c^a)&(b|a)); }
+V foo_167_2(V a, V b, V c) { return ((b|a)&c)^~a; }
+V foo_167_3(V a, V b, V c) { return (~((b|a)&c))^a; }
+
+V foo_168_1(V a, V b, V c) { return (b|a)&c; }
+
+V foo_169_1(V a, V b, V c) { return ~((b|a)^c); }
+V foo_169_2(V a, V b, V c) { return (~(b|a))^c; }
+V foo_169_3(V a, V b, V c) { return (b|a)^~c; }
+
+V foo_170_1(V a, V b, V c) { return c; }
+
+V foo_171_1(V a, V b, V c) { return (~(b|a))|c; }
+
+V foo_172_1(V a, V b, V c) { return ((c^b)&a)^b; }
+
+V foo_173_1(V a, V b, V c) { return ~(((c&b)|a)^c); }
+V foo_173_2(V a, V b, V c) { return (~((c&b)|a))^c; }
+V foo_173_3(V a, V b, V c) { return ((c&b)|a)^~c; }
+V foo_173_4(V a, V b, V c) { return (~(c^a))|(c&b); }
+
+V foo_174_1(V a, V b, V c) { return (~a&b)|c; }
+
+V foo_175_1(V a, V b, V c) { return ~a|c; }
+
+V foo_176_1(V a, V b, V c) { return (~b|c)&a; }
+
+V foo_177_1(V a, V b, V c) { return ~((c&a)^(c|b)); }
+V foo_177_2(V a, V b, V c) { return ((b^a)|c)^~a; }
+V foo_177_3(V a, V b, V c) { return (~(c|b))|(c&a); }
+V foo_177_4(V a, V b, V c) { return (~(c|b))^(c&a); }
+V foo_177_5(V a, V b, V c) { return (~((b^a)|c))^a; }
+V foo_177_6(V a, V b, V c) { return (~(c&a))^(c|b); }
+V foo_177_7(V a, V b, V c) { return ((b^a)|~c)^b; }
+
+V foo_178_1(V a, V b, V c) { return ((b^a)&(c^a))^c; }
+V foo_178_2(V a, V b, V c) { return ((c^a)&(c^b))^a; }
+V foo_178_3(V a, V b, V c) { return ((c^a)&b)^(c|a); }
+V foo_178_4(V a, V b, V c) { return ((b^a)|(c^a))^b; }
+
+V foo_179_1(V a, V b, V c) { return (c&a)|~b; }
+
+V foo_180_1(V a, V b, V c) { return (~c&b)^a; }
+
+V foo_181_1(V a, V b, V c) { return ~((c^a)&(c|b)); }
+V foo_181_2(V a, V b, V c) { return (~((c|b)&a))^c; }
+V foo_181_3(V a, V b, V c) { return ((c|b)&a)^~c; }
+
+V foo_182_1(V a, V b, V c) { return (((c&a)|b)^a)^c; }
+V foo_182_2(V a, V b, V c) { return ((c|a)^b)|(c&a); }
+V foo_182_3(V a, V b, V c) { return (((c&a)|b)^c)^a; }
+V foo_182_4(V a, V b, V c) { return ((c&a)|b)^(c^a); }
+V foo_182_5(V a, V b, V c) { return ((b^a)^c)|(c&a); }
+
+V foo_183_1(V a, V b, V c) { return ~((c^a)&b); }
+
+V foo_184_1(V a, V b, V c) { return ((c^a)&b)^a; }
+
+V foo_185_1(V a, V b, V c) { return ~(((c&a)|b)^c); }
+V foo_185_2(V a, V b, V c) { return (~((c&a)|b))^c; }
+V foo_185_3(V a, V b, V c) { return ((c&a)|b)^~c; }
+V foo_185_4(V a, V b, V c) { return (~(c^b))|(c&a); }
+
+V foo_186_1(V a, V b, V c) { return (~b&a)|c; }
+
+V foo_187_1(V a, V b, V c) { return ~b|c; }
+
+V foo_188_1(V a, V b, V c) { return (b^a)|(c&b); }
+V foo_188_2(V a, V b, V c) { return (b^a)|(c&a); }
+
+V foo_189_1(V a, V b, V c) { return ~((c^a)&(c^b)); }
+V foo_189_2(V a, V b, V c) { return (~(c^b))|(b^a); }
+V foo_189_3(V a, V b, V c) { return (~(c^a))|(b^a); }
+
+V foo_190_1(V a, V b, V c) { return (b^a)|c; }
+
+V foo_191_1(V a, V b, V c) { return (~(b&a))|c; }
+
+V foo_192_1(V a, V b, V c) { return b&a; }
+
+V foo_193_1(V a, V b, V c) { return ~((~a&c)|(b^a)); }
+V foo_193_2(V a, V b, V c) { return (~((~b&c)|a))^b; }
+V foo_193_3(V a, V b, V c) { return ((~a&c)|b)^~a; }
+V foo_193_4(V a, V b, V c) { return (~((~a&c)|b))^a; }
+V foo_193_5(V a, V b, V c) { return ((~b&c)|a)^~b; }
+V foo_193_6(V a, V b, V c) { return (~(b^a))&(~c|b); }
+V foo_193_7(V a, V b, V c) { return (~(b^a))&(~c|a); }
+
+V foo_194_1(V a, V b, V c) { return ((c|b)&~a)^b; }
+V foo_194_2(V a, V b, V c) { return ((c|a)&~b)^a; }
+V foo_194_3(V a, V b, V c) { return (~(b^a))&(c|b); }
+V foo_194_4(V a, V b, V c) { return (~(b^a))&(c|a); }
+
+V foo_195_1(V a, V b, V c) { return ~(b^a); }
+V foo_195_2(V a, V b, V c) { return ~a^b; }
+V foo_195_3(V a, V b, V c) { return ~b^a; }
+
+V foo_196_1(V a, V b, V c) { return (~c|a)&b; }
+
+V foo_197_1(V a, V b, V c) { return ~((b&a)^(c|a)); }
+V foo_197_2(V a, V b, V c) { return (~(c|a))|(b&a); }
+V foo_197_3(V a, V b, V c) { return (~(c|a))^(b&a); }
+V foo_197_4(V a, V b, V c) { return (~((c^b)|a))^b; }
+V foo_197_5(V a, V b, V c) { return ((c^b)|a)^~b; }
+V foo_197_6(V a, V b, V c) { return (~(b&a))^(c|a); }
+V foo_197_7(V a, V b, V c) { return ((c^b)|~a)^c; }
+
+V foo_198_1(V a, V b, V c) { return (~a&c)^b; }
+
+V foo_199_1(V a, V b, V c) { return ~((b^a)&(c|a)); }
+V foo_199_2(V a, V b, V c) { return ((c|a)&b)^~a; }
+V foo_199_3(V a, V b, V c) { return (~((c|a)&b))^a; }
+
+V foo_200_1(V a, V b, V c) { return (c|a)&b; }
+
+V foo_201_1(V a, V b, V c) { return ~((c|a)^b); }
+V foo_201_2(V a, V b, V c) { return (~(c|a))^b; }
+V foo_201_3(V a, V b, V c) { return (c|a)^~b; }
+
+V foo_202_1(V a, V b, V c) { return ((c^b)&a)^c; }
+
+V foo_203_1(V a, V b, V c) { return ~(((c&b)|a)^b); }
+V foo_203_2(V a, V b, V c) { return (~((c&b)|a))^b; }
+V foo_203_3(V a, V b, V c) { return ((c&b)|a)^~b; }
+V foo_203_4(V a, V b, V c) { return (~(b^a))|(c&b); }
+
+V foo_204_1(V a, V b, V c) { return b; }
+
+V foo_205_1(V a, V b, V c) { return (~(c|a))|b; }
+
+V foo_206_1(V a, V b, V c) { return (~a&c)|b; }
+
+V foo_207_1(V a, V b, V c) { return ~a|b; }
+
+V foo_208_1(V a, V b, V c) { return (~c|b)&a; }
+
+V foo_209_1(V a, V b, V c) { return ~((b&a)^(c|b)); }
+V foo_209_2(V a, V b, V c) { return ((c^a)|b)^~a; }
+V foo_209_3(V a, V b, V c) { return (~(c|b))|(b&a); }
+V foo_209_4(V a, V b, V c) { return (~(c|b))^(b&a); }
+V foo_209_5(V a, V b, V c) { return (~((c^a)|b))^a; }
+V foo_209_6(V a, V b, V c) { return (~(b&a))^(c|b); }
+V foo_209_7(V a, V b, V c) { return ((c^a)|~b)^c; }
+
+V foo_210_1(V a, V b, V c) { return (~b&c)^a; }
+
+V foo_211_1(V a, V b, V c) { return ~((b^a)&(c|b)); }
+V foo_211_2(V a, V b, V c) { return (~((c|b)&a))^b; }
+V foo_211_3(V a, V b, V c) { return ((c|b)&a)^~b; }
+
+V foo_212_1(V a, V b, V c) { return ((b^a)&(c^a))^b; }
+V foo_212_2(V a, V b, V c) { return ((b^a)&(c^b))^a; }
+V foo_212_3(V a, V b, V c) { return ((b^a)&c)^(b|a); }
+V foo_212_4(V a, V b, V c) { return ((b^a)|(c^a))^c; }
+
+V foo_213_1(V a, V b, V c) { return (b&a)|~c; }
+
+V foo_214_1(V a, V b, V c) { return (((b&a)|c)^a)^b; }
+V foo_214_2(V a, V b, V c) { return (((b&a)|c)^b)^a; }
+V foo_214_3(V a, V b, V c) { return ((b&a)|c)^(b^a); }
+V foo_214_4(V a, V b, V c) { return ((b|a)^c)|(b&a); }
+V foo_214_5(V a, V b, V c) { return ((b^a)^c)|(b&a); }
+
+V foo_215_1(V a, V b, V c) { return ~((b^a)&c); }
+
+V foo_216_1(V a, V b, V c) { return ((b^a)&c)^a; }
+
+V foo_217_1(V a, V b, V c) { return ~(((b&a)|c)^b); }
+V foo_217_2(V a, V b, V c) { return (~((b&a)|c))^b; }
+V foo_217_3(V a, V b, V c) { return ((b&a)|c)^~b; }
+V foo_217_4(V a, V b, V c) { return (~(c^b))|(b&a); }
+
+V foo_218_1(V a, V b, V c) { return (c^a)|(c&b); }
+V foo_218_2(V a, V b, V c) { return (c^a)|(b&a); }
+
+V foo_219_1(V a, V b, V c) { return ~((b^a)&(c^b)); }
+V foo_219_2(V a, V b, V c) { return (~(c^b))|(c^a); }
+V foo_219_3(V a, V b, V c) { return (~(b^a))|(c^a); }
+
+V foo_220_1(V a, V b, V c) { return (~c&a)|b; }
+
+V foo_221_1(V a, V b, V c) { return ~c|b; }
+
+V foo_222_1(V a, V b, V c) { return (c^a)|b; }
+
+V foo_223_1(V a, V b, V c) { return (~(c&a))|b; }
+
+V foo_224_1(V a, V b, V c) { return (c|b)&a; }
+
+V foo_225_1(V a, V b, V c) { return ~((c|b)^a); }
+V foo_225_2(V a, V b, V c) { return (c|b)^~a; }
+V foo_225_3(V a, V b, V c) { return (~(c|b))^a; }
+
+V foo_226_1(V a, V b, V c) { return ((c^a)&b)^c; }
+
+V foo_227_1(V a, V b, V c) { return ~(((c&a)|b)^a); }
+V foo_227_2(V a, V b, V c) { return ((c&a)|b)^~a; }
+V foo_227_3(V a, V b, V c) { return (~((c&a)|b))^a; }
+V foo_227_4(V a, V b, V c) { return (~(b^a))|(c&a); }
+
+V foo_228_1(V a, V b, V c) { return ((b^a)&c)^b; }
+
+V foo_229_1(V a, V b, V c) { return ~(((b&a)|c)^a); }
+V foo_229_2(V a, V b, V c) { return ((b&a)|c)^~a; }
+V foo_229_3(V a, V b, V c) { return (~((b&a)|c))^a; }
+V foo_229_4(V a, V b, V c) { return (~(c^a))|(b&a); }
+
+V foo_230_1(V a, V b, V c) { return (c^b)|(c&a); }
+V foo_230_2(V a, V b, V c) { return (c^b)|(b&a); }
+
+V foo_231_1(V a, V b, V c) { return ~((b^a)&(c^a)); }
+V foo_231_2(V a, V b, V c) { return (~(c^a))|(c^b); }
+V foo_231_3(V a, V b, V c) { return (~(b^a))|(c^b); }
+
+V foo_232_1(V a, V b, V c) { return ((b^a)&(c^a))^a; }
+V foo_232_2(V a, V b, V c) { return ((b^a)&(c^b))^b; }
+V foo_232_3(V a, V b, V c) { return ((b^a)&c)|(b&a); }
+V foo_232_4(V a, V b, V c) { return ((b^a)&c)^(b&a); }
+V foo_232_5(V a, V b, V c) { return ((c^a)&(c^b))^c; }
+V foo_232_6(V a, V b, V c) { return ((c^a)&b)|(c&a); }
+V foo_232_7(V a, V b, V c) { return ((c^a)&b)^(c&a); }
+V foo_232_8(V a, V b, V c) { return ((c^b)&a)|(c&b); }
+V foo_232_9(V a, V b, V c) { return ((c^b)&a)^(c&b); }
+V foo_232_10(V a, V b, V c) { return ((c|b)&a)|(c&b); }
+V foo_232_11(V a, V b, V c) { return ((c|a)&b)|(c&a); }
+V foo_232_12(V a, V b, V c) { return ((b|a)&c)|(b&a); }
+V foo_232_13(V a, V b, V c) { return ((b&a)|c)&(b|a); }
+V foo_232_14(V a, V b, V c) { return ((c&a)|b)&(c|a); }
+V foo_232_15(V a, V b, V c) { return ((c&b)|a)&(c|b); }
+
+V foo_233_1(V a, V b, V c) { return ~(((b^a)|(c&b))^c); }
+V foo_233_2(V a, V b, V c) { return ((b&a)|c)^(~(b|a)); }
+V foo_233_3(V a, V b, V c) { return ((c&a)|b)^(~(c|a)); }
+V foo_233_4(V a, V b, V c) { return (~((c&b)|a))^(c|b); }
+V foo_233_5(V a, V b, V c) { return ((c^b)|(c&a))^~a; }
+V foo_233_6(V a, V b, V c) { return ((c&b)|a)^(~(c|b)); }
+V foo_233_7(V a, V b, V c) { return (~((c&a)|b))^(c|a); }
+V foo_233_8(V a, V b, V c) { return (~((b&a)|c))^(b|a); }
+V foo_233_9(V a, V b, V c) { return (~((c^b)|(c&a)))^a; }
+V foo_233_10(V a, V b, V c) { return (~((c^a)|(c&b)))^b; }
+V foo_233_11(V a, V b, V c) { return ((c^a)|(c&b))^~b; }
+V foo_233_12(V a, V b, V c) { return ((b&a)|~c)^(b^a); }
+V foo_233_13(V a, V b, V c) { return (~((b^a)|(c&b)))^c; }
+V foo_233_14(V a, V b, V c) { return ((b^a)|(c&b))^~c; }
+V foo_233_15(V a, V b, V c) { return ((c&a)|~b)^(c^a); }
+V foo_233_16(V a, V b, V c) { return ((c&b)|~a)^(c^b); }
+V foo_233_17(V a, V b, V c) { return (~((b^a)^c))|(c&b); }
+V foo_233_18(V a, V b, V c) { return (~((b^a)^c))|(c&a); }
+V foo_233_19(V a, V b, V c) { return (~((b^a)^c))|(b&a); }
+V foo_233_20(V a, V b, V c) { return (~((c|b)^a))|(c&b); }
+V foo_233_21(V a, V b, V c) { return (~((c|a)^b))|(c&a); }
+V foo_233_22(V a, V b, V c) { return (~((b|a)^c))|(b&a); }
+
+V foo_234_1(V a, V b, V c) { return (b&a)|c; }
+
+V foo_235_1(V a, V b, V c) { return (~(b^a))|c; }
+
+V foo_236_1(V a, V b, V c) { return (c&a)|b; }
+
+V foo_237_1(V a, V b, V c) { return (~(c^a))|b; }
+
+V foo_238_1(V a, V b, V c) { return c|b; }
+
+V foo_239_1(V a, V b, V c) { return (c|b)|~a; }
+V foo_239_2(V a, V b, V c) { return (~a|b)|c; }
+V foo_239_3(V a, V b, V c) { return (~a|c)|b; }
+
+V foo_240_1(V a, V b, V c) { return a; }
+
+V foo_241_1(V a, V b, V c) { return (~(c|b))|a; }
+
+V foo_242_1(V a, V b, V c) { return (~b&c)|a; }
+
+V foo_243_1(V a, V b, V c) { return ~b|a; }
+
+V foo_244_1(V a, V b, V c) { return (~c&b)|a; }
+
+V foo_245_1(V a, V b, V c) { return ~c|a; }
+
+V foo_246_1(V a, V b, V c) { return (c^b)|a; }
+
+V foo_247_1(V a, V b, V c) { return (~(c&b))|a; }
+
+V foo_248_1(V a, V b, V c) { return (c&b)|a; }
+
+V foo_249_1(V a, V b, V c) { return (~(c^b))|a; }
+
+V foo_250_1(V a, V b, V c) { return c|a; }
+
+V foo_251_1(V a, V b, V c) { return (c|a)|~b; }
+V foo_251_2(V a, V b, V c) { return (~b|a)|c; }
+V foo_251_3(V a, V b, V c) { return (~b|c)|a; }
+
+V foo_252_1(V a, V b, V c) { return b|a; }
+
+V foo_253_1(V a, V b, V c) { return (b|a)|~c; }
+V foo_253_2(V a, V b, V c) { return (~c|a)|b; }
+V foo_253_3(V a, V b, V c) { return (~c|b)|a; }
+
+V foo_254_1(V a, V b, V c) { return (b|a)|c; }
+V foo_254_2(V a, V b, V c) { return (c|a)|b; }
+V foo_254_3(V a, V b, V c) { return (c|b)|a; }
+
+V foo_255_1(V a, V b, V c) { return (V){~0,~0,~0,~0}; }
+
+/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]" 694 } } */
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-4.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-4.c
new file mode 100644
index 0000000..1429650
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-4.c
@@ -0,0 +1,955 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx512f" } */
+
+typedef unsigned int V __attribute__ ((__vector_size__ (32)));
+
+V foo_0_1(V a, V b, V c) { return (V){0,0,0,0}; }
+
+V foo_1_1(V a, V b, V c) { return ~((b|a)|c); }
+
+V foo_2_1(V a, V b, V c) { return (~(b|a))&c; }
+
+V foo_3_1(V a, V b, V c) { return ~(b|a); }
+
+V foo_4_1(V a, V b, V c) { return (~(c|a))&b; }
+
+V foo_5_1(V a, V b, V c) { return ~(c|a); }
+
+V foo_6_1(V a, V b, V c) { return (c^b)&~a; }
+
+V foo_7_1(V a, V b, V c) { return ~((c&b)|a); }
+
+V foo_8_1(V a, V b, V c) { return (~a&c)&b; }
+V foo_8_2(V a, V b, V c) { return (~a&b)&c; }
+V foo_8_3(V a, V b, V c) { return (c&b)&~a; }
+
+V foo_9_1(V a, V b, V c) { return ~((c^b)|a); }
+
+V foo_10_1(V a, V b, V c) { return ~a&c; }
+
+V foo_11_1(V a, V b, V c) { return ~((~c&b)|a); }
+V foo_11_2(V a, V b, V c) { return (~b|c)&~a; }
+
+V foo_12_1(V a, V b, V c) { return ~a&b; }
+
+V foo_13_1(V a, V b, V c) { return ~((~b&c)|a); }
+V foo_13_2(V a, V b, V c) { return (~c|b)&~a; }
+
+V foo_14_1(V a, V b, V c) { return (c|b)&~a; }
+
+V foo_15_1(V a, V b, V c) { return ~a; }
+
+V foo_16_1(V a, V b, V c) { return (~(c|b))&a; }
+
+V foo_17_1(V a, V b, V c) { return ~(c|b); }
+
+V foo_18_1(V a, V b, V c) { return (c^a)&~b; }
+
+V foo_19_1(V a, V b, V c) { return ~((c&a)|b); }
+
+V foo_20_1(V a, V b, V c) { return (b^a)&~c; }
+
+V foo_21_1(V a, V b, V c) { return ~((b&a)|c); }
+
+V foo_22_1(V a, V b, V c) { return ((b^a)|(c&b))^c; }
+V foo_22_2(V a, V b, V c) { return ((c^a)|(c&b))^b; }
+V foo_22_3(V a, V b, V c) { return ((c^b)|(c&a))^a; }
+V foo_22_4(V a, V b, V c) { return ((b&a)|c)^(b|a); }
+V foo_22_5(V a, V b, V c) { return ((c&a)|b)^(c|a); }
+V foo_22_6(V a, V b, V c) { return ((c&b)|a)^(c|b); }
+
+V foo_23_1(V a, V b, V c) { return ~(((b^a)&(c^a))^a); }
+V foo_23_2(V a, V b, V c) { return ((b^a)&(c^a))^~a; }
+V foo_23_3(V a, V b, V c) { return ((b^a)&(c^b))^~b; }
+V foo_23_4(V a, V b, V c) { return ((b^a)&c)^(~(b&a)); }
+V foo_23_5(V a, V b, V c) { return ((c^a)&(c^b))^~c; }
+V foo_23_6(V a, V b, V c) { return ((c^a)&b)^(~(c&a)); }
+V foo_23_7(V a, V b, V c) { return ((c^b)&a)^(~(c&b)); }
+V foo_23_8(V a, V b, V c) { return (~((c^b)&a))^(c&b); }
+V foo_23_9(V a, V b, V c) { return (~((c^a)&b))^(c&a); }
+V foo_23_10(V a, V b, V c) { return (~((c^a)&(c^b)))^c; }
+V foo_23_11(V a, V b, V c) { return (~((b^a)&c))^(b&a); }
+V foo_23_12(V a, V b, V c) { return (~((b^a)&(c^b)))^b; }
+V foo_23_13(V a, V b, V c) { return (~((b^a)&(c^a)))^a; }
+V foo_23_14(V a, V b, V c) { return ((~(b^a))|c)^(b|a); }
+V foo_23_15(V a, V b, V c) { return ((~(c^a))|b)^(c|a); }
+V foo_23_16(V a, V b, V c) { return ((~(c^b))|a)^(c|b); }
+
+V foo_24_1(V a, V b, V c) { return (b^a)&(c^a); }
+
+V foo_25_1(V a, V b, V c) { return ~((c^b)|(c&a)); }
+V foo_25_2(V a, V b, V c) { return ((c&a)|~b)^c; }
+V foo_25_3(V a, V b, V c) { return ((b&a)|~c)^b; }
+
+V foo_26_1(V a, V b, V c) { return ((b&a)|c)^a; }
+
+V foo_27_1(V a, V b, V c) { return ~(((b^a)&c)^b); }
+V foo_27_2(V a, V b, V c) { return ((b^a)&c)^~b; }
+V foo_27_3(V a, V b, V c) { return (~b|c)^(c&a); }
+V foo_27_4(V a, V b, V c) { return (~((b^a)&c))^b; }
+V foo_27_5(V a, V b, V c) { return ((~(b^a))|c)^a; }
+V foo_27_6(V a, V b, V c) { return (~c|a)^(c|b); }
+
+V foo_28_1(V a, V b, V c) { return ((c&a)|b)^a; }
+
+V foo_29_1(V a, V b, V c) { return ~(((c^a)&b)^c); }
+V foo_29_2(V a, V b, V c) { return ((c^a)&b)^~c; }
+V foo_29_3(V a, V b, V c) { return (~((c^a)&b))^c; }
+V foo_29_4(V a, V b, V c) { return (~c|b)^(b&a); }
+V foo_29_5(V a, V b, V c) { return ((~(c^a))|b)^a; }
+V foo_29_6(V a, V b, V c) { return (~b|a)^(c|b); }
+
+V foo_30_1(V a, V b, V c) { return (c|b)^a; }
+
+V foo_31_1(V a, V b, V c) { return ~((c|b)&a); }
+
+V foo_32_1(V a, V b, V c) { return (~b&c)&a; }
+V foo_32_2(V a, V b, V c) { return (~b&a)&c; }
+V foo_32_3(V a, V b, V c) { return (c&a)&~b; }
+
+V foo_33_1(V a, V b, V c) { return ~((c^a)|b); }
+
+V foo_34_1(V a, V b, V c) { return ~b&c; }
+
+V foo_35_1(V a, V b, V c) { return ~((~c&a)|b); }
+V foo_35_2(V a, V b, V c) { return (~a|c)&~b; }
+
+V foo_36_1(V a, V b, V c) { return (b^a)&(c^b); }
+
+V foo_37_1(V a, V b, V c) { return ~((c^a)|(c&b)); }
+V foo_37_2(V a, V b, V c) { return ((c&b)|~a)^c; }
+V foo_37_3(V a, V b, V c) { return ((b&a)|~c)^a; }
+
+V foo_38_1(V a, V b, V c) { return ((b&a)|c)^b; }
+
+V foo_39_1(V a, V b, V c) { return ~(((b^a)&c)^a); }
+V foo_39_2(V a, V b, V c) { return ((b^a)&c)^~a; }
+V foo_39_3(V a, V b, V c) { return (~a|c)^(c&b); }
+V foo_39_4(V a, V b, V c) { return ((~(b^a))|c)^b; }
+V foo_39_5(V a, V b, V c) { return (~((b^a)&c))^a; }
+V foo_39_6(V a, V b, V c) { return (~c|b)^(c|a); }
+
+V foo_40_1(V a, V b, V c) { return (b^a)&c; }
+
+V foo_41_1(V a, V b, V c) { return ~((((b&a)|c)^a)^b); }
+V foo_41_2(V a, V b, V c) { return (((b&a)|c)^b)^~a; }
+V foo_41_3(V a, V b, V c) { return (~((b&a)|c))^(b^a); }
+V foo_41_4(V a, V b, V c) { return (((b&a)|c)^a)^~b; }
+V foo_41_5(V a, V b, V c) { return ((b&a)|c)^(~(b^a)); }
+V foo_41_6(V a, V b, V c) { return (~(((b&a)|c)^a))^b; }
+V foo_41_7(V a, V b, V c) { return ((b&a)|~c)^(b|a); }
+V foo_41_8(V a, V b, V c) { return (~(((b&a)|c)^b))^a; }
+
+V foo_42_1(V a, V b, V c) { return (~(b&a))&c; }
+
+V foo_43_1(V a, V b, V c) { return ~(((b^a)&(c^a))^b); }
+V foo_43_2(V a, V b, V c) { return ((b^a)&c)|(~(b|a)); }
+V foo_43_3(V a, V b, V c) { return ((b^a)&c)^(~(b|a)); }
+V foo_43_4(V a, V b, V c) { return ((b^a)&(c^b))^~a; }
+V foo_43_5(V a, V b, V c) { return ((b^a)&(c^a))^~b; }
+V foo_43_6(V a, V b, V c) { return ((b^a)|(c^a))^~c; }
+V foo_43_7(V a, V b, V c) { return (~((b^a)|(c^a)))^c; }
+V foo_43_8(V a, V b, V c) { return ((~(b^a))|c)^(b&a); }
+V foo_43_9(V a, V b, V c) { return (~((b^a)&(c^a)))^b; }
+V foo_43_10(V a, V b, V c) { return (~((b^a)&c))^(b|a); }
+V foo_43_11(V a, V b, V c) { return (~((b^a)&(c^b)))^a; }
+V foo_43_12(V a, V b, V c) { return ((c^b)|a)^(~c|b); }
+V foo_43_13(V a, V b, V c) { return ((c^a)|b)^(~c|a); }
+
+V foo_44_1(V a, V b, V c) { return (b^a)&(c|b); }
+V foo_44_2(V a, V b, V c) { return ((c|b)&a)^b; }
+
+V foo_45_1(V a, V b, V c) { return (~c|b)^a; }
+
+V foo_46_1(V a, V b, V c) { return (b&a)^(c|b); }
+V foo_46_2(V a, V b, V c) { return ((c^a)|b)^a; }
+
+V foo_47_1(V a, V b, V c) { return ~((~c|b)&a); }
+V foo_47_2(V a, V b, V c) { return (~b&c)|~a; }
+
+V foo_48_1(V a, V b, V c) { return ~b&a; }
+
+V foo_49_1(V a, V b, V c) { return ~((~a&c)|b); }
+V foo_49_2(V a, V b, V c) { return (~c|a)&~b; }
+
+V foo_50_1(V a, V b, V c) { return (c|a)&~b; }
+
+V foo_51_1(V a, V b, V c) { return ~b; }
+
+V foo_52_1(V a, V b, V c) { return ((c&b)|a)^b; }
+
+V foo_53_1(V a, V b, V c) { return ~(((c^b)&a)^c); }
+V foo_53_2(V a, V b, V c) { return ((c^b)&a)^~c; }
+V foo_53_3(V a, V b, V c) { return (~((c^b)&a))^c; }
+V foo_53_4(V a, V b, V c) { return (~c|a)^(b&a); }
+V foo_53_5(V a, V b, V c) { return ((~(c^b))|a)^b; }
+V foo_53_6(V a, V b, V c) { return (~a|b)^(c|a); }
+
+V foo_54_1(V a, V b, V c) { return (c|a)^b; }
+
+V foo_55_1(V a, V b, V c) { return ~((c|a)&b); }
+
+V foo_56_1(V a, V b, V c) { return (b^a)&(c|a); }
+V foo_56_2(V a, V b, V c) { return ((c|a)&b)^a; }
+
+V foo_57_1(V a, V b, V c) { return (~c|a)^b; }
+
+V foo_58_1(V a, V b, V c) { return (b&a)^(c|a); }
+V foo_58_2(V a, V b, V c) { return ((c^b)|a)^b; }
+
+V foo_59_1(V a, V b, V c) { return ~((~c|a)&b); }
+V foo_59_2(V a, V b, V c) { return (~a&c)|~b; }
+
+V foo_60_1(V a, V b, V c) { return b^a; }
+
+V foo_61_1(V a, V b, V c) { return (~(c|a))|(b^a); }
+V foo_61_2(V a, V b, V c) { return (~(c|b))|(b^a); }
+V foo_61_3(V a, V b, V c) { return ((~(c|b))|a)^b; }
+V foo_61_4(V a, V b, V c) { return ((~(c|a))|b)^a; }
+
+V foo_62_1(V a, V b, V c) { return (~a&c)|(b^a); }
+V foo_62_2(V a, V b, V c) { return (~b&c)|(b^a); }
+V foo_62_3(V a, V b, V c) { return ((~b&c)|a)^b; }
+V foo_62_4(V a, V b, V c) { return ((~a&c)|b)^a; }
+
+V foo_63_1(V a, V b, V c) { return ~(b&a); }
+
+V foo_64_1(V a, V b, V c) { return (~c&b)&a; }
+V foo_64_2(V a, V b, V c) { return (~c&a)&b; }
+V foo_64_3(V a, V b, V c) { return (b&a)&~c; }
+
+V foo_65_1(V a, V b, V c) { return ~((b^a)|c); }
+
+V foo_66_1(V a, V b, V c) { return (c^a)&(c^b); }
+
+V foo_67_1(V a, V b, V c) { return ~((b^a)|(c&b)); }
+V foo_67_2(V a, V b, V c) { return ((c&b)|~a)^b; }
+V foo_67_3(V a, V b, V c) { return ((c&a)|~b)^a; }
+
+V foo_68_1(V a, V b, V c) { return ~c&b; }
+
+V foo_69_1(V a, V b, V c) { return ~((~b&a)|c); }
+V foo_69_2(V a, V b, V c) { return (~a|b)&~c; }
+
+V foo_70_1(V a, V b, V c) { return ((c&a)|b)^c; }
+
+V foo_71_1(V a, V b, V c) { return ~(((c^a)&b)^a); }
+V foo_71_2(V a, V b, V c) { return ((c^a)&b)^~a; }
+V foo_71_3(V a, V b, V c) { return (~a|b)^(c&b); }
+V foo_71_4(V a, V b, V c) { return ((~(c^a))|b)^c; }
+V foo_71_5(V a, V b, V c) { return (~((c^a)&b))^a; }
+V foo_71_6(V a, V b, V c) { return (~b|c)^(b|a); }
+
+V foo_72_1(V a, V b, V c) { return (c^a)&b; }
+
+V foo_73_1(V a, V b, V c) { return ~((((c&a)|b)^a)^c); }
+V foo_73_2(V a, V b, V c) { return (((c&a)|b)^c)^~a; }
+V foo_73_3(V a, V b, V c) { return (~((c&a)|b))^(c^a); }
+V foo_73_4(V a, V b, V c) { return (((c&a)|b)^a)^~c; }
+V foo_73_5(V a, V b, V c) { return ((c&a)|b)^(~(c^a)); }
+V foo_73_6(V a, V b, V c) { return (~(((c&a)|b)^a))^c; }
+V foo_73_7(V a, V b, V c) { return ((c&a)|~b)^(c|a); }
+V foo_73_8(V a, V b, V c) { return (~(((c&a)|b)^c))^a; }
+
+V foo_74_1(V a, V b, V c) { return (c^a)&(c|b); }
+V foo_74_2(V a, V b, V c) { return ((c|b)&a)^c; }
+
+V foo_75_1(V a, V b, V c) { return (~b|c)^a; }
+
+V foo_76_1(V a, V b, V c) { return (~(c&a))&b; }
+
+V foo_77_1(V a, V b, V c) { return ~(((b^a)&(c^a))^c); }
+V foo_77_2(V a, V b, V c) { return ((c^a)&b)|(~(c|a)); }
+V foo_77_3(V a, V b, V c) { return ((c^a)&b)^(~(c|a)); }
+V foo_77_4(V a, V b, V c) { return ((c^a)&(c^b))^~a; }
+V foo_77_5(V a, V b, V c) { return ((b^a)&(c^a))^~c; }
+V foo_77_6(V a, V b, V c) { return ((b^a)|(c^a))^~b; }
+V foo_77_7(V a, V b, V c) { return (~((b^a)|(c^a)))^b; }
+V foo_77_8(V a, V b, V c) { return ((~(c^a))|b)^(c&a); }
+V foo_77_9(V a, V b, V c) { return (~((b^a)&(c^a)))^c; }
+V foo_77_10(V a, V b, V c) { return (~((c^a)&b))^(c|a); }
+V foo_77_11(V a, V b, V c) { return ((c^b)|a)^(~b|c); }
+V foo_77_12(V a, V b, V c) { return (~((c^a)&(c^b)))^a; }
+V foo_77_13(V a, V b, V c) { return ((b^a)|c)^(~b|a); }
+
+V foo_78_1(V a, V b, V c) { return (c&a)^(c|b); }
+V foo_78_2(V a, V b, V c) { return ((b^a)|c)^a; }
+
+V foo_79_1(V a, V b, V c) { return ~((~b|c)&a); }
+V foo_79_2(V a, V b, V c) { return (~c&b)|~a; }
+
+V foo_80_1(V a, V b, V c) { return ~c&a; }
+
+V foo_81_1(V a, V b, V c) { return ~((~a&b)|c); }
+V foo_81_2(V a, V b, V c) { return (~b|a)&~c; }
+
+V foo_82_1(V a, V b, V c) { return ((c&b)|a)^c; }
+
+V foo_83_1(V a, V b, V c) { return ~(((c^b)&a)^b); }
+V foo_83_2(V a, V b, V c) { return ((c^b)&a)^~b; }
+V foo_83_3(V a, V b, V c) { return (~((c^b)&a))^b; }
+V foo_83_4(V a, V b, V c) { return (~b|a)^(c&a); }
+V foo_83_5(V a, V b, V c) { return ((~(c^b))|a)^c; }
+V foo_83_6(V a, V b, V c) { return (~a|c)^(b|a); }
+
+V foo_84_1(V a, V b, V c) { return (b|a)&~c; }
+
+V foo_85_1(V a, V b, V c) { return ~c; }
+
+V foo_86_1(V a, V b, V c) { return (b|a)^c; }
+
+V foo_87_1(V a, V b, V c) { return ~((b|a)&c); }
+
+V foo_88_1(V a, V b, V c) { return (c^a)&(b|a); }
+V foo_88_2(V a, V b, V c) { return ((b|a)&c)^a; }
+
+V foo_89_1(V a, V b, V c) { return (~b|a)^c; }
+
+V foo_90_1(V a, V b, V c) { return c^a; }
+
+V foo_91_1(V a, V b, V c) { return (~(b|a))|(c^a); }
+V foo_91_2(V a, V b, V c) { return (~(c|b))|(c^a); }
+V foo_91_3(V a, V b, V c) { return ((~(c|b))|a)^c; }
+V foo_91_4(V a, V b, V c) { return ((~(b|a))|c)^a; }
+
+V foo_92_1(V a, V b, V c) { return (c&a)^(b|a); }
+V foo_92_2(V a, V b, V c) { return ((c^b)|a)^c; }
+
+V foo_93_1(V a, V b, V c) { return ~((~b|a)&c); }
+V foo_93_2(V a, V b, V c) { return (~a&b)|~c; }
+
+V foo_94_1(V a, V b, V c) { return (~a&b)|(c^a); }
+V foo_94_2(V a, V b, V c) { return (~c&b)|(c^a); }
+V foo_94_3(V a, V b, V c) { return ((~c&b)|a)^c; }
+V foo_94_4(V a, V b, V c) { return ((~a&b)|c)^a; }
+
+V foo_95_1(V a, V b, V c) { return ~(c&a); }
+
+V foo_96_1(V a, V b, V c) { return (c^b)&a; }
+
+V foo_97_1(V a, V b, V c) { return ~(((c|b)^a)|(c&b)); }
+V foo_97_2(V a, V b, V c) { return (~((c&b)|a))^(c^b); }
+V foo_97_3(V a, V b, V c) { return (((c&b)|a)^c)^~b; }
+V foo_97_4(V a, V b, V c) { return (((c&b)|a)^b)^~c; }
+V foo_97_5(V a, V b, V c) { return ((c&b)|~a)^(c|b); }
+V foo_97_6(V a, V b, V c) { return ((c&b)|a)^(~(c^b)); }
+V foo_97_7(V a, V b, V c) { return (~(((c&b)|a)^b))^c; }
+V foo_97_8(V a, V b, V c) { return (~(((c&b)|a)^c))^b; }
+
+V foo_98_1(V a, V b, V c) { return (c^b)&(c|a); }
+V foo_98_2(V a, V b, V c) { return ((c|a)&b)^c; }
+
+V foo_99_1(V a, V b, V c) { return (~a|c)^b; }
+
+V foo_100_1(V a, V b, V c) { return (c^b)&(b|a); }
+V foo_100_2(V a, V b, V c) { return ((b|a)&c)^b; }
+
+V foo_101_1(V a, V b, V c) { return (~a|b)^c; }
+
+V foo_102_1(V a, V b, V c) { return c^b; }
+
+V foo_103_1(V a, V b, V c) { return (~(b|a))|(c^b); }
+V foo_103_2(V a, V b, V c) { return (~(c|a))|(c^b); }
+V foo_103_3(V a, V b, V c) { return ((~(c|a))|b)^c; }
+V foo_103_4(V a, V b, V c) { return ((~(b|a))|c)^b; }
+
+V foo_104_1(V a, V b, V c) { return ((b&a)^c)&(b|a); }
+V foo_104_2(V a, V b, V c) { return ((c&a)^b)&(c|a); }
+V foo_104_3(V a, V b, V c) { return ((c&b)^a)&(c|b); }
+V foo_104_4(V a, V b, V c) { return ((c|b)&a)^(c&b); }
+V foo_104_5(V a, V b, V c) { return ((c|a)&b)^(c&a); }
+V foo_104_6(V a, V b, V c) { return ((b|a)&c)^(b&a); }
+
+V foo_105_1(V a, V b, V c) { return ~((b^a)^c); }
+V foo_105_2(V a, V b, V c) { return (c^b)^~a; }
+V foo_105_3(V a, V b, V c) { return (c^a)^~b; }
+V foo_105_4(V a, V b, V c) { return (b^a)^~c; }
+V foo_105_5(V a, V b, V c) { return (~(c^b))^a; }
+V foo_105_6(V a, V b, V c) { return (~(c^a))^b; }
+V foo_105_7(V a, V b, V c) { return (~(b^a))^c; }
+
+V foo_106_1(V a, V b, V c) { return (b&a)^c; }
+
+V foo_107_1(V a, V b, V c) { return ~(((b|a)&c)^(b^a)); }
+V foo_107_2(V a, V b, V c) { return ((b&a)^c)|(~(b|a)); }
+V foo_107_3(V a, V b, V c) { return ((c^b)&(b|a))^~a; }
+V foo_107_4(V a, V b, V c) { return ((c^a)&(b|a))^~b; }
+V foo_107_5(V a, V b, V c) { return (~((b|a)&c))^(b^a); }
+V foo_107_6(V a, V b, V c) { return (~((c^b)&(b|a)))^a; }
+V foo_107_7(V a, V b, V c) { return (~((c^a)&(b|a)))^b; }
+V foo_107_8(V a, V b, V c) { return ((b|a)&c)^(~(b^a)); }
+V foo_107_9(V a, V b, V c) { return ((~(b|a))|c)^(b&a); }
+
+V foo_108_1(V a, V b, V c) { return (c&a)^b; }
+
+V foo_109_1(V a, V b, V c) { return ~(((b^a)&(c|a))^c); }
+V foo_109_2(V a, V b, V c) { return ((c&a)^b)|(~(c|a)); }
+V foo_109_3(V a, V b, V c) { return ((c^b)&(c|a))^~a; }
+V foo_109_4(V a, V b, V c) { return (~((c|a)&b))^(c^a); }
+V foo_109_5(V a, V b, V c) { return ((b^a)&(c|a))^~c; }
+V foo_109_6(V a, V b, V c) { return (~((c^b)&(c|a)))^a; }
+V foo_109_7(V a, V b, V c) { return ((~(c|a))|b)^(c&a); }
+V foo_109_8(V a, V b, V c) { return ((c|a)&b)^(~(c^a)); }
+V foo_109_9(V a, V b, V c) { return (~((b^a)&(c|a)))^c; }
+
+V foo_110_1(V a, V b, V c) { return (~a&c)|(c^b); }
+V foo_110_2(V a, V b, V c) { return (~a&b)|(c^b); }
+V foo_110_3(V a, V b, V c) { return ((~b|a)&c)^b; }
+V foo_110_4(V a, V b, V c) { return ((~c|a)&b)^c; }
+
+V foo_111_1(V a, V b, V c) { return (c^b)|~a; }
+
+V foo_112_1(V a, V b, V c) { return (~(c&b))&a; }
+
+V foo_113_1(V a, V b, V c) { return ~(((b^a)&(c^b))^c); }
+V foo_113_2(V a, V b, V c) { return ((b^a)|(c^a))^~a; }
+V foo_113_3(V a, V b, V c) { return ((c^b)&a)|(~(c|b)); }
+V foo_113_4(V a, V b, V c) { return ((c^b)&a)^(~(c|b)); }
+V foo_113_5(V a, V b, V c) { return ((b^a)&(c^b))^~c; }
+V foo_113_6(V a, V b, V c) { return ((c^a)&(c^b))^~b; }
+V foo_113_7(V a, V b, V c) { return (~((b^a)|(c^a)))^a; }
+V foo_113_8(V a, V b, V c) { return ((~(c^b))|a)^(c&b); }
+V foo_113_9(V a, V b, V c) { return (~((c^b)&a))^(c|b); }
+V foo_113_10(V a, V b, V c) { return (~((b^a)&(c^b)))^c; }
+V foo_113_11(V a, V b, V c) { return ((c^a)|b)^(~a|c); }
+V foo_113_12(V a, V b, V c) { return (~((c^a)&(c^b)))^b; }
+V foo_113_13(V a, V b, V c) { return ((b^a)|c)^(~a|b); }
+
+V foo_114_1(V a, V b, V c) { return (c&b)^(c|a); }
+V foo_114_2(V a, V b, V c) { return ((b^a)|c)^b; }
+
+V foo_115_1(V a, V b, V c) { return ~((~a|c)&b); }
+V foo_115_2(V a, V b, V c) { return (~c&a)|~b; }
+
+V foo_116_1(V a, V b, V c) { return (c&b)^(b|a); }
+V foo_116_2(V a, V b, V c) { return ((c^a)|b)^c; }
+
+V foo_117_1(V a, V b, V c) { return ~((~a|b)&c); }
+V foo_117_2(V a, V b, V c) { return (~b&a)|~c; }
+
+V foo_118_1(V a, V b, V c) { return (~b&a)|(c^b); }
+V foo_118_2(V a, V b, V c) { return (~c&a)|(c^b); }
+V foo_118_3(V a, V b, V c) { return ((~c&a)|b)^c; }
+V foo_118_4(V a, V b, V c) { return ((~b&a)|c)^b; }
+
+V foo_119_1(V a, V b, V c) { return ~(c&b); }
+
+V foo_120_1(V a, V b, V c) { return (c&b)^a; }
+
+V foo_121_1(V a, V b, V c) { return ~(((b^a)&(c|b))^c); }
+V foo_121_2(V a, V b, V c) { return ((c&b)^a)|(~(c|b)); }
+V foo_121_3(V a, V b, V c) { return (~((c|b)&a))^(c^b); }
+V foo_121_4(V a, V b, V c) { return ((b^a)&(c|b))^~c; }
+V foo_121_5(V a, V b, V c) { return ((c^a)&(c|b))^~b; }
+V foo_121_6(V a, V b, V c) { return ((~(c|b))|a)^(c&b); }
+V foo_121_7(V a, V b, V c) { return ((c|b)&a)^(~(c^b)); }
+V foo_121_8(V a, V b, V c) { return (~((b^a)&(c|b)))^c; }
+V foo_121_9(V a, V b, V c) { return (~((c^a)&(c|b)))^b; }
+
+V foo_122_1(V a, V b, V c) { return (~b&c)|(c^a); }
+V foo_122_2(V a, V b, V c) { return (~b&a)|(c^a); }
+V foo_122_3(V a, V b, V c) { return ((~a|b)&c)^a; }
+V foo_122_4(V a, V b, V c) { return ((~c|b)&a)^c; }
+
+V foo_123_1(V a, V b, V c) { return (c^a)|~b; }
+
+V foo_124_1(V a, V b, V c) { return (~c&b)|(b^a); }
+V foo_124_2(V a, V b, V c) { return (~c&a)|(b^a); }
+V foo_124_3(V a, V b, V c) { return ((~a|c)&b)^a; }
+V foo_124_4(V a, V b, V c) { return ((~b|c)&a)^b; }
+
+V foo_125_1(V a, V b, V c) { return (b^a)|~c; }
+
+V foo_126_1(V a, V b, V c) { return (b^a)|(c^a); }
+V foo_126_2(V a, V b, V c) { return (b^a)|(c^b); }
+V foo_126_3(V a, V b, V c) { return (c^a)|(c^b); }
+
+V foo_127_1(V a, V b, V c) { return ~((c&b)&a); }
+
+V foo_128_1(V a, V b, V c) { return (c&b)&a; }
+V foo_128_2(V a, V b, V c) { return (c&a)&b; }
+V foo_128_3(V a, V b, V c) { return (b&a)&c; }
+
+V foo_129_1(V a, V b, V c) { return ~((b^a)|(c^a)); }
+
+V foo_130_1(V a, V b, V c) { return (~(b^a))&c; }
+
+V foo_131_1(V a, V b, V c) { return ~((~c&b)|(b^a)); }
+V foo_131_2(V a, V b, V c) { return ((~a|c)&b)^~a; }
+V foo_131_3(V a, V b, V c) { return ((~b|c)&a)^~b; }
+V foo_131_4(V a, V b, V c) { return (~((~b|c)&a))^b; }
+V foo_131_5(V a, V b, V c) { return (~((~a|c)&b))^a; }
+V foo_131_6(V a, V b, V c) { return (~a|c)&(~(b^a)); }
+V foo_131_7(V a, V b, V c) { return (~b|c)&(~(b^a)); }
+
+V foo_132_1(V a, V b, V c) { return (~(c^a))&b; }
+
+V foo_133_1(V a, V b, V c) { return ~((~b&c)|(c^a)); }
+V foo_133_2(V a, V b, V c) { return ((~a|b)&c)^~a; }
+V foo_133_3(V a, V b, V c) { return (~((~c|b)&a))^c; }
+V foo_133_4(V a, V b, V c) { return ((~c|b)&a)^~c; }
+V foo_133_5(V a, V b, V c) { return (~((~a|b)&c))^a; }
+V foo_133_6(V a, V b, V c) { return (~(c^a))&(~a|b); }
+V foo_133_7(V a, V b, V c) { return (~(c^a))&(~c|b); }
+
+V foo_134_1(V a, V b, V c) { return ((b^a)&(c|b))^c; }
+V foo_134_2(V a, V b, V c) { return ((c^a)&(c|b))^b; }
+V foo_134_3(V a, V b, V c) { return ((c|b)&a)^(c^b); }
+V foo_134_4(V a, V b, V c) { return ((b^a)^c)&(c|b); }
+
+V foo_135_1(V a, V b, V c) { return ~((c&b)^a); }
+V foo_135_2(V a, V b, V c) { return (c&b)^~a; }
+V foo_135_3(V a, V b, V c) { return (~(c&b))^a; }
+
+V foo_136_1(V a, V b, V c) { return c&b; }
+
+V foo_137_1(V a, V b, V c) { return ~((~b&a)|(c^b)); }
+V foo_137_2(V a, V b, V c) { return (~((~c&a)|b))^c; }
+V foo_137_3(V a, V b, V c) { return ((~b&a)|c)^~b; }
+V foo_137_4(V a, V b, V c) { return (~((~b&a)|c))^b; }
+V foo_137_5(V a, V b, V c) { return ((~c&a)|b)^~c; }
+V foo_137_6(V a, V b, V c) { return (~(c^b))&(~a|c); }
+V foo_137_7(V a, V b, V c) { return (~(c^b))&(~a|b); }
+
+V foo_138_1(V a, V b, V c) { return (~a|b)&c; }
+
+V foo_139_1(V a, V b, V c) { return ~((c&b)^(b|a)); }
+V foo_139_2(V a, V b, V c) { return (~(b|a))|(c&b); }
+V foo_139_3(V a, V b, V c) { return (~(b|a))^(c&b); }
+V foo_139_4(V a, V b, V c) { return (~((c^a)|b))^c; }
+V foo_139_5(V a, V b, V c) { return ((c^a)|b)^~c; }
+V foo_139_6(V a, V b, V c) { return (~(c&b))^(b|a); }
+V foo_139_7(V a, V b, V c) { return ((c^a)|~b)^a; }
+
+V foo_140_1(V a, V b, V c) { return (~a|c)&b; }
+
+V foo_141_1(V a, V b, V c) { return ~((c&b)^(c|a)); }
+V foo_141_2(V a, V b, V c) { return (~(c|a))|(c&b); }
+V foo_141_3(V a, V b, V c) { return (~(c|a))^(c&b); }
+V foo_141_4(V a, V b, V c) { return ((b^a)|c)^~b; }
+V foo_141_5(V a, V b, V c) { return (~((b^a)|c))^b; }
+V foo_141_6(V a, V b, V c) { return (~(c&b))^(c|a); }
+V foo_141_7(V a, V b, V c) { return ((b^a)|~c)^a; }
+
+V foo_142_1(V a, V b, V c) { return ((b^a)&(c^b))^c; }
+V foo_142_2(V a, V b, V c) { return ((c^a)&(c^b))^b; }
+V foo_142_3(V a, V b, V c) { return ((c^b)&a)^(c|b); }
+V foo_142_4(V a, V b, V c) { return ((b^a)|(c^a))^a; }
+
+V foo_143_1(V a, V b, V c) { return (c&b)|~a; }
+
+V foo_144_1(V a, V b, V c) { return (~(c^b))&a; }
+
+V foo_145_1(V a, V b, V c) { return ~((~a&c)|(c^b)); }
+V foo_145_2(V a, V b, V c) { return ((~b|a)&c)^~b; }
+V foo_145_3(V a, V b, V c) { return (~((~c|a)&b))^c; }
+V foo_145_4(V a, V b, V c) { return ((~c|a)&b)^~c; }
+V foo_145_5(V a, V b, V c) { return (~((~b|a)&c))^b; }
+V foo_145_6(V a, V b, V c) { return (~(c^b))&(~b|a); }
+V foo_145_7(V a, V b, V c) { return (~(c^b))&(~c|a); }
+
+V foo_146_1(V a, V b, V c) { return ((b^a)&(c|a))^c; }
+V foo_146_2(V a, V b, V c) { return ((c|a)&b)^(c^a); }
+V foo_146_3(V a, V b, V c) { return ((c^b)&(c|a))^a; }
+V foo_146_4(V a, V b, V c) { return ((b^a)^c)&(c|a); }
+
+V foo_147_1(V a, V b, V c) { return ~((c&a)^b); }
+V foo_147_2(V a, V b, V c) { return (c&a)^~b; }
+V foo_147_3(V a, V b, V c) { return (~(c&a))^b; }
+
+V foo_148_1(V a, V b, V c) { return ((b|a)&c)^(b^a); }
+V foo_148_2(V a, V b, V c) { return ((c^a)&(b|a))^b; }
+V foo_148_3(V a, V b, V c) { return ((c^b)&(b|a))^a; }
+V foo_148_4(V a, V b, V c) { return ((b^a)^c)&(b|a); }
+
+V foo_149_1(V a, V b, V c) { return ~((b&a)^c); }
+V foo_149_2(V a, V b, V c) { return (~(b&a))^c; }
+V foo_149_3(V a, V b, V c) { return (b&a)^~c; }
+
+V foo_150_1(V a, V b, V c) { return (b^a)^c; }
+V foo_150_2(V a, V b, V c) { return (c^a)^b; }
+V foo_150_3(V a, V b, V c) { return (c^b)^a; }
+
+V foo_151_1(V a, V b, V c) { return ~(((b&a)^c)&(b|a)); }
+V foo_151_2(V a, V b, V c) { return ((b^a)^c)|(~(b|a)); }
+V foo_151_3(V a, V b, V c) { return ((b^a)^c)|(~(c|a)); }
+V foo_151_4(V a, V b, V c) { return ((b^a)^c)|(~(c|b)); }
+V foo_151_5(V a, V b, V c) { return (~((c|b)&a))^(c&b); }
+V foo_151_6(V a, V b, V c) { return (~((c|a)&b))^(c&a); }
+V foo_151_7(V a, V b, V c) { return ((~(b|a))|c)^(b^a); }
+V foo_151_8(V a, V b, V c) { return ((~(c|a))|(b^a))^c; }
+V foo_151_9(V a, V b, V c) { return ((b|a)&c)^(~(b&a)); }
+V foo_151_10(V a, V b, V c) { return (~((b|a)&c))^(b&a); }
+V foo_151_11(V a, V b, V c) { return ((~(c|a))|b)^(c^a); }
+V foo_151_12(V a, V b, V c) { return ((~(b|a))|(c^a))^b; }
+V foo_151_13(V a, V b, V c) { return ((c|a)&b)^(~(c&a)); }
+V foo_151_14(V a, V b, V c) { return ((~(c|b))|a)^(c^b); }
+V foo_151_15(V a, V b, V c) { return ((~(b|a))|(c^b))^a; }
+V foo_151_16(V a, V b, V c) { return ((c|b)&a)^(~(c&b)); }
+
+V foo_152_1(V a, V b, V c) { return ((c|a)&~b)^c; }
+V foo_152_2(V a, V b, V c) { return ((b|a)&~c)^b; }
+V foo_152_3(V a, V b, V c) { return (~(c^b))&(c|a); }
+V foo_152_4(V a, V b, V c) { return (~(c^b))&(b|a); }
+
+V foo_153_1(V a, V b, V c) { return ~(c^b); }
+V foo_153_2(V a, V b, V c) { return ~b^c; }
+V foo_153_3(V a, V b, V c) { return ~c^b; }
+
+V foo_154_1(V a, V b, V c) { return (~b&a)^c; }
+
+V foo_155_1(V a, V b, V c) { return ~((c^b)&(b|a)); }
+V foo_155_2(V a, V b, V c) { return ((b|a)&c)^~b; }
+V foo_155_3(V a, V b, V c) { return (~((b|a)&c))^b; }
+
+V foo_156_1(V a, V b, V c) { return (~c&a)^b; }
+
+V foo_157_1(V a, V b, V c) { return ~((c^b)&(c|a)); }
+V foo_157_2(V a, V b, V c) { return (~((c|a)&b))^c; }
+V foo_157_3(V a, V b, V c) { return ((c|a)&b)^~c; }
+
+V foo_158_1(V a, V b, V c) { return ((c|b)^a)|(c&b); }
+V foo_158_2(V a, V b, V c) { return (((c&b)|a)^b)^c; }
+V foo_158_3(V a, V b, V c) { return (((c&b)|a)^c)^b; }
+V foo_158_4(V a, V b, V c) { return ((c&b)|a)^(c^b); }
+V foo_158_5(V a, V b, V c) { return ((b^a)^c)|(c&b); }
+
+V foo_159_1(V a, V b, V c) { return ~((c^b)&a); }
+
+V foo_160_1(V a, V b, V c) { return c&a; }
+
+V foo_161_1(V a, V b, V c) { return ~((~a&b)|(c^a)); }
+V foo_161_2(V a, V b, V c) { return (~((~c&b)|a))^c; }
+V foo_161_3(V a, V b, V c) { return ((~a&b)|c)^~a; }
+V foo_161_4(V a, V b, V c) { return (~((~a&b)|c))^a; }
+V foo_161_5(V a, V b, V c) { return ((~c&b)|a)^~c; }
+V foo_161_6(V a, V b, V c) { return (~(c^a))&(~b|c); }
+V foo_161_7(V a, V b, V c) { return (~(c^a))&(~b|a); }
+
+V foo_162_1(V a, V b, V c) { return (~b|a)&c; }
+
+V foo_163_1(V a, V b, V c) { return ~((c&a)^(b|a)); }
+V foo_163_2(V a, V b, V c) { return (~(b|a))|(c&a); }
+V foo_163_3(V a, V b, V c) { return (~(b|a))^(c&a); }
+V foo_163_4(V a, V b, V c) { return (~((c^b)|a))^c; }
+V foo_163_5(V a, V b, V c) { return ((c^b)|a)^~c; }
+V foo_163_6(V a, V b, V c) { return (~(c&a))^(b|a); }
+V foo_163_7(V a, V b, V c) { return ((c^b)|~a)^b; }
+
+V foo_164_1(V a, V b, V c) { return ((c|b)&~a)^c; }
+V foo_164_2(V a, V b, V c) { return ((b|a)&~c)^a; }
+V foo_164_3(V a, V b, V c) { return (~(c^a))&(c|b); }
+V foo_164_4(V a, V b, V c) { return (~(c^a))&(b|a); }
+
+V foo_165_1(V a, V b, V c) { return ~(c^a); }
+V foo_165_2(V a, V b, V c) { return ~a^c; }
+V foo_165_3(V a, V b, V c) { return ~c^a; }
+
+V foo_166_1(V a, V b, V c) { return (~a&b)^c; }
+
+V foo_167_1(V a, V b, V c) { return ~((c^a)&(b|a)); }
+V foo_167_2(V a, V b, V c) { return ((b|a)&c)^~a; }
+V foo_167_3(V a, V b, V c) { return (~((b|a)&c))^a; }
+
+V foo_168_1(V a, V b, V c) { return (b|a)&c; }
+
+V foo_169_1(V a, V b, V c) { return ~((b|a)^c); }
+V foo_169_2(V a, V b, V c) { return (~(b|a))^c; }
+V foo_169_3(V a, V b, V c) { return (b|a)^~c; }
+
+V foo_170_1(V a, V b, V c) { return c; }
+
+V foo_171_1(V a, V b, V c) { return (~(b|a))|c; }
+
+V foo_172_1(V a, V b, V c) { return ((c^b)&a)^b; }
+
+V foo_173_1(V a, V b, V c) { return ~(((c&b)|a)^c); }
+V foo_173_2(V a, V b, V c) { return (~((c&b)|a))^c; }
+V foo_173_3(V a, V b, V c) { return ((c&b)|a)^~c; }
+V foo_173_4(V a, V b, V c) { return (~(c^a))|(c&b); }
+
+V foo_174_1(V a, V b, V c) { return (~a&b)|c; }
+
+V foo_175_1(V a, V b, V c) { return ~a|c; }
+
+V foo_176_1(V a, V b, V c) { return (~b|c)&a; }
+
+V foo_177_1(V a, V b, V c) { return ~((c&a)^(c|b)); }
+V foo_177_2(V a, V b, V c) { return ((b^a)|c)^~a; }
+V foo_177_3(V a, V b, V c) { return (~(c|b))|(c&a); }
+V foo_177_4(V a, V b, V c) { return (~(c|b))^(c&a); }
+V foo_177_5(V a, V b, V c) { return (~((b^a)|c))^a; }
+V foo_177_6(V a, V b, V c) { return (~(c&a))^(c|b); }
+V foo_177_7(V a, V b, V c) { return ((b^a)|~c)^b; }
+
+V foo_178_1(V a, V b, V c) { return ((b^a)&(c^a))^c; }
+V foo_178_2(V a, V b, V c) { return ((c^a)&(c^b))^a; }
+V foo_178_3(V a, V b, V c) { return ((c^a)&b)^(c|a); }
+V foo_178_4(V a, V b, V c) { return ((b^a)|(c^a))^b; }
+
+V foo_179_1(V a, V b, V c) { return (c&a)|~b; }
+
+V foo_180_1(V a, V b, V c) { return (~c&b)^a; }
+
+V foo_181_1(V a, V b, V c) { return ~((c^a)&(c|b)); }
+V foo_181_2(V a, V b, V c) { return (~((c|b)&a))^c; }
+V foo_181_3(V a, V b, V c) { return ((c|b)&a)^~c; }
+
+V foo_182_1(V a, V b, V c) { return (((c&a)|b)^a)^c; }
+V foo_182_2(V a, V b, V c) { return ((c|a)^b)|(c&a); }
+V foo_182_3(V a, V b, V c) { return (((c&a)|b)^c)^a; }
+V foo_182_4(V a, V b, V c) { return ((c&a)|b)^(c^a); }
+V foo_182_5(V a, V b, V c) { return ((b^a)^c)|(c&a); }
+
+V foo_183_1(V a, V b, V c) { return ~((c^a)&b); }
+
+V foo_184_1(V a, V b, V c) { return ((c^a)&b)^a; }
+
+V foo_185_1(V a, V b, V c) { return ~(((c&a)|b)^c); }
+V foo_185_2(V a, V b, V c) { return (~((c&a)|b))^c; }
+V foo_185_3(V a, V b, V c) { return ((c&a)|b)^~c; }
+V foo_185_4(V a, V b, V c) { return (~(c^b))|(c&a); }
+
+V foo_186_1(V a, V b, V c) { return (~b&a)|c; }
+
+V foo_187_1(V a, V b, V c) { return ~b|c; }
+
+V foo_188_1(V a, V b, V c) { return (b^a)|(c&b); }
+V foo_188_2(V a, V b, V c) { return (b^a)|(c&a); }
+
+V foo_189_1(V a, V b, V c) { return ~((c^a)&(c^b)); }
+V foo_189_2(V a, V b, V c) { return (~(c^b))|(b^a); }
+V foo_189_3(V a, V b, V c) { return (~(c^a))|(b^a); }
+
+V foo_190_1(V a, V b, V c) { return (b^a)|c; }
+
+V foo_191_1(V a, V b, V c) { return (~(b&a))|c; }
+
+V foo_192_1(V a, V b, V c) { return b&a; }
+
+V foo_193_1(V a, V b, V c) { return ~((~a&c)|(b^a)); }
+V foo_193_2(V a, V b, V c) { return (~((~b&c)|a))^b; }
+V foo_193_3(V a, V b, V c) { return ((~a&c)|b)^~a; }
+V foo_193_4(V a, V b, V c) { return (~((~a&c)|b))^a; }
+V foo_193_5(V a, V b, V c) { return ((~b&c)|a)^~b; }
+V foo_193_6(V a, V b, V c) { return (~(b^a))&(~c|b); }
+V foo_193_7(V a, V b, V c) { return (~(b^a))&(~c|a); }
+
+V foo_194_1(V a, V b, V c) { return ((c|b)&~a)^b; }
+V foo_194_2(V a, V b, V c) { return ((c|a)&~b)^a; }
+V foo_194_3(V a, V b, V c) { return (~(b^a))&(c|b); }
+V foo_194_4(V a, V b, V c) { return (~(b^a))&(c|a); }
+
+V foo_195_1(V a, V b, V c) { return ~(b^a); }
+V foo_195_2(V a, V b, V c) { return ~a^b; }
+V foo_195_3(V a, V b, V c) { return ~b^a; }
+
+V foo_196_1(V a, V b, V c) { return (~c|a)&b; }
+
+V foo_197_1(V a, V b, V c) { return ~((b&a)^(c|a)); }
+V foo_197_2(V a, V b, V c) { return (~(c|a))|(b&a); }
+V foo_197_3(V a, V b, V c) { return (~(c|a))^(b&a); }
+V foo_197_4(V a, V b, V c) { return (~((c^b)|a))^b; }
+V foo_197_5(V a, V b, V c) { return ((c^b)|a)^~b; }
+V foo_197_6(V a, V b, V c) { return (~(b&a))^(c|a); }
+V foo_197_7(V a, V b, V c) { return ((c^b)|~a)^c; }
+
+V foo_198_1(V a, V b, V c) { return (~a&c)^b; }
+
+V foo_199_1(V a, V b, V c) { return ~((b^a)&(c|a)); }
+V foo_199_2(V a, V b, V c) { return ((c|a)&b)^~a; }
+V foo_199_3(V a, V b, V c) { return (~((c|a)&b))^a; }
+
+V foo_200_1(V a, V b, V c) { return (c|a)&b; }
+
+V foo_201_1(V a, V b, V c) { return ~((c|a)^b); }
+V foo_201_2(V a, V b, V c) { return (~(c|a))^b; }
+V foo_201_3(V a, V b, V c) { return (c|a)^~b; }
+
+V foo_202_1(V a, V b, V c) { return ((c^b)&a)^c; }
+
+V foo_203_1(V a, V b, V c) { return ~(((c&b)|a)^b); }
+V foo_203_2(V a, V b, V c) { return (~((c&b)|a))^b; }
+V foo_203_3(V a, V b, V c) { return ((c&b)|a)^~b; }
+V foo_203_4(V a, V b, V c) { return (~(b^a))|(c&b); }
+
+V foo_204_1(V a, V b, V c) { return b; }
+
+V foo_205_1(V a, V b, V c) { return (~(c|a))|b; }
+
+V foo_206_1(V a, V b, V c) { return (~a&c)|b; }
+
+V foo_207_1(V a, V b, V c) { return ~a|b; }
+
+V foo_208_1(V a, V b, V c) { return (~c|b)&a; }
+
+V foo_209_1(V a, V b, V c) { return ~((b&a)^(c|b)); }
+V foo_209_2(V a, V b, V c) { return ((c^a)|b)^~a; }
+V foo_209_3(V a, V b, V c) { return (~(c|b))|(b&a); }
+V foo_209_4(V a, V b, V c) { return (~(c|b))^(b&a); }
+V foo_209_5(V a, V b, V c) { return (~((c^a)|b))^a; }
+V foo_209_6(V a, V b, V c) { return (~(b&a))^(c|b); }
+V foo_209_7(V a, V b, V c) { return ((c^a)|~b)^c; }
+
+V foo_210_1(V a, V b, V c) { return (~b&c)^a; }
+
+V foo_211_1(V a, V b, V c) { return ~((b^a)&(c|b)); }
+V foo_211_2(V a, V b, V c) { return (~((c|b)&a))^b; }
+V foo_211_3(V a, V b, V c) { return ((c|b)&a)^~b; }
+
+V foo_212_1(V a, V b, V c) { return ((b^a)&(c^a))^b; }
+V foo_212_2(V a, V b, V c) { return ((b^a)&(c^b))^a; }
+V foo_212_3(V a, V b, V c) { return ((b^a)&c)^(b|a); }
+V foo_212_4(V a, V b, V c) { return ((b^a)|(c^a))^c; }
+
+V foo_213_1(V a, V b, V c) { return (b&a)|~c; }
+
+V foo_214_1(V a, V b, V c) { return (((b&a)|c)^a)^b; }
+V foo_214_2(V a, V b, V c) { return (((b&a)|c)^b)^a; }
+V foo_214_3(V a, V b, V c) { return ((b&a)|c)^(b^a); }
+V foo_214_4(V a, V b, V c) { return ((b|a)^c)|(b&a); }
+V foo_214_5(V a, V b, V c) { return ((b^a)^c)|(b&a); }
+
+V foo_215_1(V a, V b, V c) { return ~((b^a)&c); }
+
+V foo_216_1(V a, V b, V c) { return ((b^a)&c)^a; }
+
+V foo_217_1(V a, V b, V c) { return ~(((b&a)|c)^b); }
+V foo_217_2(V a, V b, V c) { return (~((b&a)|c))^b; }
+V foo_217_3(V a, V b, V c) { return ((b&a)|c)^~b; }
+V foo_217_4(V a, V b, V c) { return (~(c^b))|(b&a); }
+
+V foo_218_1(V a, V b, V c) { return (c^a)|(c&b); }
+V foo_218_2(V a, V b, V c) { return (c^a)|(b&a); }
+
+V foo_219_1(V a, V b, V c) { return ~((b^a)&(c^b)); }
+V foo_219_2(V a, V b, V c) { return (~(c^b))|(c^a); }
+V foo_219_3(V a, V b, V c) { return (~(b^a))|(c^a); }
+
+V foo_220_1(V a, V b, V c) { return (~c&a)|b; }
+
+V foo_221_1(V a, V b, V c) { return ~c|b; }
+
+V foo_222_1(V a, V b, V c) { return (c^a)|b; }
+
+V foo_223_1(V a, V b, V c) { return (~(c&a))|b; }
+
+V foo_224_1(V a, V b, V c) { return (c|b)&a; }
+
+V foo_225_1(V a, V b, V c) { return ~((c|b)^a); }
+V foo_225_2(V a, V b, V c) { return (c|b)^~a; }
+V foo_225_3(V a, V b, V c) { return (~(c|b))^a; }
+
+V foo_226_1(V a, V b, V c) { return ((c^a)&b)^c; }
+
+V foo_227_1(V a, V b, V c) { return ~(((c&a)|b)^a); }
+V foo_227_2(V a, V b, V c) { return ((c&a)|b)^~a; }
+V foo_227_3(V a, V b, V c) { return (~((c&a)|b))^a; }
+V foo_227_4(V a, V b, V c) { return (~(b^a))|(c&a); }
+
+V foo_228_1(V a, V b, V c) { return ((b^a)&c)^b; }
+
+V foo_229_1(V a, V b, V c) { return ~(((b&a)|c)^a); }
+V foo_229_2(V a, V b, V c) { return ((b&a)|c)^~a; }
+V foo_229_3(V a, V b, V c) { return (~((b&a)|c))^a; }
+V foo_229_4(V a, V b, V c) { return (~(c^a))|(b&a); }
+
+V foo_230_1(V a, V b, V c) { return (c^b)|(c&a); }
+V foo_230_2(V a, V b, V c) { return (c^b)|(b&a); }
+
+V foo_231_1(V a, V b, V c) { return ~((b^a)&(c^a)); }
+V foo_231_2(V a, V b, V c) { return (~(c^a))|(c^b); }
+V foo_231_3(V a, V b, V c) { return (~(b^a))|(c^b); }
+
+V foo_232_1(V a, V b, V c) { return ((b^a)&(c^a))^a; }
+V foo_232_2(V a, V b, V c) { return ((b^a)&(c^b))^b; }
+V foo_232_3(V a, V b, V c) { return ((b^a)&c)|(b&a); }
+V foo_232_4(V a, V b, V c) { return ((b^a)&c)^(b&a); }
+V foo_232_5(V a, V b, V c) { return ((c^a)&(c^b))^c; }
+V foo_232_6(V a, V b, V c) { return ((c^a)&b)|(c&a); }
+V foo_232_7(V a, V b, V c) { return ((c^a)&b)^(c&a); }
+V foo_232_8(V a, V b, V c) { return ((c^b)&a)|(c&b); }
+V foo_232_9(V a, V b, V c) { return ((c^b)&a)^(c&b); }
+V foo_232_10(V a, V b, V c) { return ((c|b)&a)|(c&b); }
+V foo_232_11(V a, V b, V c) { return ((c|a)&b)|(c&a); }
+V foo_232_12(V a, V b, V c) { return ((b|a)&c)|(b&a); }
+V foo_232_13(V a, V b, V c) { return ((b&a)|c)&(b|a); }
+V foo_232_14(V a, V b, V c) { return ((c&a)|b)&(c|a); }
+V foo_232_15(V a, V b, V c) { return ((c&b)|a)&(c|b); }
+
+V foo_233_1(V a, V b, V c) { return ~(((b^a)|(c&b))^c); }
+V foo_233_2(V a, V b, V c) { return ((b&a)|c)^(~(b|a)); }
+V foo_233_3(V a, V b, V c) { return ((c&a)|b)^(~(c|a)); }
+V foo_233_4(V a, V b, V c) { return (~((c&b)|a))^(c|b); }
+V foo_233_5(V a, V b, V c) { return ((c^b)|(c&a))^~a; }
+V foo_233_6(V a, V b, V c) { return ((c&b)|a)^(~(c|b)); }
+V foo_233_7(V a, V b, V c) { return (~((c&a)|b))^(c|a); }
+V foo_233_8(V a, V b, V c) { return (~((b&a)|c))^(b|a); }
+V foo_233_9(V a, V b, V c) { return (~((c^b)|(c&a)))^a; }
+V foo_233_10(V a, V b, V c) { return (~((c^a)|(c&b)))^b; }
+V foo_233_11(V a, V b, V c) { return ((c^a)|(c&b))^~b; }
+V foo_233_12(V a, V b, V c) { return ((b&a)|~c)^(b^a); }
+V foo_233_13(V a, V b, V c) { return (~((b^a)|(c&b)))^c; }
+V foo_233_14(V a, V b, V c) { return ((b^a)|(c&b))^~c; }
+V foo_233_15(V a, V b, V c) { return ((c&a)|~b)^(c^a); }
+V foo_233_16(V a, V b, V c) { return ((c&b)|~a)^(c^b); }
+V foo_233_17(V a, V b, V c) { return (~((b^a)^c))|(c&b); }
+V foo_233_18(V a, V b, V c) { return (~((b^a)^c))|(c&a); }
+V foo_233_19(V a, V b, V c) { return (~((b^a)^c))|(b&a); }
+V foo_233_20(V a, V b, V c) { return (~((c|b)^a))|(c&b); }
+V foo_233_21(V a, V b, V c) { return (~((c|a)^b))|(c&a); }
+V foo_233_22(V a, V b, V c) { return (~((b|a)^c))|(b&a); }
+
+V foo_234_1(V a, V b, V c) { return (b&a)|c; }
+
+V foo_235_1(V a, V b, V c) { return (~(b^a))|c; }
+
+V foo_236_1(V a, V b, V c) { return (c&a)|b; }
+
+V foo_237_1(V a, V b, V c) { return (~(c^a))|b; }
+
+V foo_238_1(V a, V b, V c) { return c|b; }
+
+V foo_239_1(V a, V b, V c) { return (c|b)|~a; }
+V foo_239_2(V a, V b, V c) { return (~a|b)|c; }
+V foo_239_3(V a, V b, V c) { return (~a|c)|b; }
+
+V foo_240_1(V a, V b, V c) { return a; }
+
+V foo_241_1(V a, V b, V c) { return (~(c|b))|a; }
+
+V foo_242_1(V a, V b, V c) { return (~b&c)|a; }
+
+V foo_243_1(V a, V b, V c) { return ~b|a; }
+
+V foo_244_1(V a, V b, V c) { return (~c&b)|a; }
+
+V foo_245_1(V a, V b, V c) { return ~c|a; }
+
+V foo_246_1(V a, V b, V c) { return (c^b)|a; }
+
+V foo_247_1(V a, V b, V c) { return (~(c&b))|a; }
+
+V foo_248_1(V a, V b, V c) { return (c&b)|a; }
+
+V foo_249_1(V a, V b, V c) { return (~(c^b))|a; }
+
+V foo_250_1(V a, V b, V c) { return c|a; }
+
+V foo_251_1(V a, V b, V c) { return (c|a)|~b; }
+V foo_251_2(V a, V b, V c) { return (~b|a)|c; }
+V foo_251_3(V a, V b, V c) { return (~b|c)|a; }
+
+V foo_252_1(V a, V b, V c) { return b|a; }
+
+V foo_253_1(V a, V b, V c) { return (b|a)|~c; }
+V foo_253_2(V a, V b, V c) { return (~c|a)|b; }
+V foo_253_3(V a, V b, V c) { return (~c|b)|a; }
+
+V foo_254_1(V a, V b, V c) { return (b|a)|c; }
+V foo_254_2(V a, V b, V c) { return (c|a)|b; }
+V foo_254_3(V a, V b, V c) { return (c|b)|a; }
+
+V foo_255_1(V a, V b, V c) { return (V){~0,~0,~0,~0}; }
+
+/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]" 694 } } */
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-5.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-5.c
new file mode 100644
index 0000000..3dbd954
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-5.c
@@ -0,0 +1,955 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx512f" } */
+
+typedef unsigned int V __attribute__ ((__vector_size__ (64)));
+
+V foo_0_1(V a, V b, V c) { return (V){0,0,0,0}; }
+
+V foo_1_1(V a, V b, V c) { return ~((b|a)|c); }
+
+V foo_2_1(V a, V b, V c) { return (~(b|a))&c; }
+
+V foo_3_1(V a, V b, V c) { return ~(b|a); }
+
+V foo_4_1(V a, V b, V c) { return (~(c|a))&b; }
+
+V foo_5_1(V a, V b, V c) { return ~(c|a); }
+
+V foo_6_1(V a, V b, V c) { return (c^b)&~a; }
+
+V foo_7_1(V a, V b, V c) { return ~((c&b)|a); }
+
+V foo_8_1(V a, V b, V c) { return (~a&c)&b; }
+V foo_8_2(V a, V b, V c) { return (~a&b)&c; }
+V foo_8_3(V a, V b, V c) { return (c&b)&~a; }
+
+V foo_9_1(V a, V b, V c) { return ~((c^b)|a); }
+
+V foo_10_1(V a, V b, V c) { return ~a&c; }
+
+V foo_11_1(V a, V b, V c) { return ~((~c&b)|a); }
+V foo_11_2(V a, V b, V c) { return (~b|c)&~a; }
+
+V foo_12_1(V a, V b, V c) { return ~a&b; }
+
+V foo_13_1(V a, V b, V c) { return ~((~b&c)|a); }
+V foo_13_2(V a, V b, V c) { return (~c|b)&~a; }
+
+V foo_14_1(V a, V b, V c) { return (c|b)&~a; }
+
+V foo_15_1(V a, V b, V c) { return ~a; }
+
+V foo_16_1(V a, V b, V c) { return (~(c|b))&a; }
+
+V foo_17_1(V a, V b, V c) { return ~(c|b); }
+
+V foo_18_1(V a, V b, V c) { return (c^a)&~b; }
+
+V foo_19_1(V a, V b, V c) { return ~((c&a)|b); }
+
+V foo_20_1(V a, V b, V c) { return (b^a)&~c; }
+
+V foo_21_1(V a, V b, V c) { return ~((b&a)|c); }
+
+V foo_22_1(V a, V b, V c) { return ((b^a)|(c&b))^c; }
+V foo_22_2(V a, V b, V c) { return ((c^a)|(c&b))^b; }
+V foo_22_3(V a, V b, V c) { return ((c^b)|(c&a))^a; }
+V foo_22_4(V a, V b, V c) { return ((b&a)|c)^(b|a); }
+V foo_22_5(V a, V b, V c) { return ((c&a)|b)^(c|a); }
+V foo_22_6(V a, V b, V c) { return ((c&b)|a)^(c|b); }
+
+V foo_23_1(V a, V b, V c) { return ~(((b^a)&(c^a))^a); }
+V foo_23_2(V a, V b, V c) { return ((b^a)&(c^a))^~a; }
+V foo_23_3(V a, V b, V c) { return ((b^a)&(c^b))^~b; }
+V foo_23_4(V a, V b, V c) { return ((b^a)&c)^(~(b&a)); }
+V foo_23_5(V a, V b, V c) { return ((c^a)&(c^b))^~c; }
+V foo_23_6(V a, V b, V c) { return ((c^a)&b)^(~(c&a)); }
+V foo_23_7(V a, V b, V c) { return ((c^b)&a)^(~(c&b)); }
+V foo_23_8(V a, V b, V c) { return (~((c^b)&a))^(c&b); }
+V foo_23_9(V a, V b, V c) { return (~((c^a)&b))^(c&a); }
+V foo_23_10(V a, V b, V c) { return (~((c^a)&(c^b)))^c; }
+V foo_23_11(V a, V b, V c) { return (~((b^a)&c))^(b&a); }
+V foo_23_12(V a, V b, V c) { return (~((b^a)&(c^b)))^b; }
+V foo_23_13(V a, V b, V c) { return (~((b^a)&(c^a)))^a; }
+V foo_23_14(V a, V b, V c) { return ((~(b^a))|c)^(b|a); }
+V foo_23_15(V a, V b, V c) { return ((~(c^a))|b)^(c|a); }
+V foo_23_16(V a, V b, V c) { return ((~(c^b))|a)^(c|b); }
+
+V foo_24_1(V a, V b, V c) { return (b^a)&(c^a); }
+
+V foo_25_1(V a, V b, V c) { return ~((c^b)|(c&a)); }
+V foo_25_2(V a, V b, V c) { return ((c&a)|~b)^c; }
+V foo_25_3(V a, V b, V c) { return ((b&a)|~c)^b; }
+
+V foo_26_1(V a, V b, V c) { return ((b&a)|c)^a; }
+
+V foo_27_1(V a, V b, V c) { return ~(((b^a)&c)^b); }
+V foo_27_2(V a, V b, V c) { return ((b^a)&c)^~b; }
+V foo_27_3(V a, V b, V c) { return (~b|c)^(c&a); }
+V foo_27_4(V a, V b, V c) { return (~((b^a)&c))^b; }
+V foo_27_5(V a, V b, V c) { return ((~(b^a))|c)^a; }
+V foo_27_6(V a, V b, V c) { return (~c|a)^(c|b); }
+
+V foo_28_1(V a, V b, V c) { return ((c&a)|b)^a; }
+
+V foo_29_1(V a, V b, V c) { return ~(((c^a)&b)^c); }
+V foo_29_2(V a, V b, V c) { return ((c^a)&b)^~c; }
+V foo_29_3(V a, V b, V c) { return (~((c^a)&b))^c; }
+V foo_29_4(V a, V b, V c) { return (~c|b)^(b&a); }
+V foo_29_5(V a, V b, V c) { return ((~(c^a))|b)^a; }
+V foo_29_6(V a, V b, V c) { return (~b|a)^(c|b); }
+
+V foo_30_1(V a, V b, V c) { return (c|b)^a; }
+
+V foo_31_1(V a, V b, V c) { return ~((c|b)&a); }
+
+V foo_32_1(V a, V b, V c) { return (~b&c)&a; }
+V foo_32_2(V a, V b, V c) { return (~b&a)&c; }
+V foo_32_3(V a, V b, V c) { return (c&a)&~b; }
+
+V foo_33_1(V a, V b, V c) { return ~((c^a)|b); }
+
+V foo_34_1(V a, V b, V c) { return ~b&c; }
+
+V foo_35_1(V a, V b, V c) { return ~((~c&a)|b); }
+V foo_35_2(V a, V b, V c) { return (~a|c)&~b; }
+
+V foo_36_1(V a, V b, V c) { return (b^a)&(c^b); }
+
+V foo_37_1(V a, V b, V c) { return ~((c^a)|(c&b)); }
+V foo_37_2(V a, V b, V c) { return ((c&b)|~a)^c; }
+V foo_37_3(V a, V b, V c) { return ((b&a)|~c)^a; }
+
+V foo_38_1(V a, V b, V c) { return ((b&a)|c)^b; }
+
+V foo_39_1(V a, V b, V c) { return ~(((b^a)&c)^a); }
+V foo_39_2(V a, V b, V c) { return ((b^a)&c)^~a; }
+V foo_39_3(V a, V b, V c) { return (~a|c)^(c&b); }
+V foo_39_4(V a, V b, V c) { return ((~(b^a))|c)^b; }
+V foo_39_5(V a, V b, V c) { return (~((b^a)&c))^a; }
+V foo_39_6(V a, V b, V c) { return (~c|b)^(c|a); }
+
+V foo_40_1(V a, V b, V c) { return (b^a)&c; }
+
+V foo_41_1(V a, V b, V c) { return ~((((b&a)|c)^a)^b); }
+V foo_41_2(V a, V b, V c) { return (((b&a)|c)^b)^~a; }
+V foo_41_3(V a, V b, V c) { return (~((b&a)|c))^(b^a); }
+V foo_41_4(V a, V b, V c) { return (((b&a)|c)^a)^~b; }
+V foo_41_5(V a, V b, V c) { return ((b&a)|c)^(~(b^a)); }
+V foo_41_6(V a, V b, V c) { return (~(((b&a)|c)^a))^b; }
+V foo_41_7(V a, V b, V c) { return ((b&a)|~c)^(b|a); }
+V foo_41_8(V a, V b, V c) { return (~(((b&a)|c)^b))^a; }
+
+V foo_42_1(V a, V b, V c) { return (~(b&a))&c; }
+
+V foo_43_1(V a, V b, V c) { return ~(((b^a)&(c^a))^b); }
+V foo_43_2(V a, V b, V c) { return ((b^a)&c)|(~(b|a)); }
+V foo_43_3(V a, V b, V c) { return ((b^a)&c)^(~(b|a)); }
+V foo_43_4(V a, V b, V c) { return ((b^a)&(c^b))^~a; }
+V foo_43_5(V a, V b, V c) { return ((b^a)&(c^a))^~b; }
+V foo_43_6(V a, V b, V c) { return ((b^a)|(c^a))^~c; }
+V foo_43_7(V a, V b, V c) { return (~((b^a)|(c^a)))^c; }
+V foo_43_8(V a, V b, V c) { return ((~(b^a))|c)^(b&a); }
+V foo_43_9(V a, V b, V c) { return (~((b^a)&(c^a)))^b; }
+V foo_43_10(V a, V b, V c) { return (~((b^a)&c))^(b|a); }
+V foo_43_11(V a, V b, V c) { return (~((b^a)&(c^b)))^a; }
+V foo_43_12(V a, V b, V c) { return ((c^b)|a)^(~c|b); }
+V foo_43_13(V a, V b, V c) { return ((c^a)|b)^(~c|a); }
+
+V foo_44_1(V a, V b, V c) { return (b^a)&(c|b); }
+V foo_44_2(V a, V b, V c) { return ((c|b)&a)^b; }
+
+V foo_45_1(V a, V b, V c) { return (~c|b)^a; }
+
+V foo_46_1(V a, V b, V c) { return (b&a)^(c|b); }
+V foo_46_2(V a, V b, V c) { return ((c^a)|b)^a; }
+
+V foo_47_1(V a, V b, V c) { return ~((~c|b)&a); }
+V foo_47_2(V a, V b, V c) { return (~b&c)|~a; }
+
+V foo_48_1(V a, V b, V c) { return ~b&a; }
+
+V foo_49_1(V a, V b, V c) { return ~((~a&c)|b); }
+V foo_49_2(V a, V b, V c) { return (~c|a)&~b; }
+
+V foo_50_1(V a, V b, V c) { return (c|a)&~b; }
+
+V foo_51_1(V a, V b, V c) { return ~b; }
+
+V foo_52_1(V a, V b, V c) { return ((c&b)|a)^b; }
+
+V foo_53_1(V a, V b, V c) { return ~(((c^b)&a)^c); }
+V foo_53_2(V a, V b, V c) { return ((c^b)&a)^~c; }
+V foo_53_3(V a, V b, V c) { return (~((c^b)&a))^c; }
+V foo_53_4(V a, V b, V c) { return (~c|a)^(b&a); }
+V foo_53_5(V a, V b, V c) { return ((~(c^b))|a)^b; }
+V foo_53_6(V a, V b, V c) { return (~a|b)^(c|a); }
+
+V foo_54_1(V a, V b, V c) { return (c|a)^b; }
+
+V foo_55_1(V a, V b, V c) { return ~((c|a)&b); }
+
+V foo_56_1(V a, V b, V c) { return (b^a)&(c|a); }
+V foo_56_2(V a, V b, V c) { return ((c|a)&b)^a; }
+
+V foo_57_1(V a, V b, V c) { return (~c|a)^b; }
+
+V foo_58_1(V a, V b, V c) { return (b&a)^(c|a); }
+V foo_58_2(V a, V b, V c) { return ((c^b)|a)^b; }
+
+V foo_59_1(V a, V b, V c) { return ~((~c|a)&b); }
+V foo_59_2(V a, V b, V c) { return (~a&c)|~b; }
+
+V foo_60_1(V a, V b, V c) { return b^a; }
+
+V foo_61_1(V a, V b, V c) { return (~(c|a))|(b^a); }
+V foo_61_2(V a, V b, V c) { return (~(c|b))|(b^a); }
+V foo_61_3(V a, V b, V c) { return ((~(c|b))|a)^b; }
+V foo_61_4(V a, V b, V c) { return ((~(c|a))|b)^a; }
+
+V foo_62_1(V a, V b, V c) { return (~a&c)|(b^a); }
+V foo_62_2(V a, V b, V c) { return (~b&c)|(b^a); }
+V foo_62_3(V a, V b, V c) { return ((~b&c)|a)^b; }
+V foo_62_4(V a, V b, V c) { return ((~a&c)|b)^a; }
+
+V foo_63_1(V a, V b, V c) { return ~(b&a); }
+
+V foo_64_1(V a, V b, V c) { return (~c&b)&a; }
+V foo_64_2(V a, V b, V c) { return (~c&a)&b; }
+V foo_64_3(V a, V b, V c) { return (b&a)&~c; }
+
+V foo_65_1(V a, V b, V c) { return ~((b^a)|c); }
+
+V foo_66_1(V a, V b, V c) { return (c^a)&(c^b); }
+
+V foo_67_1(V a, V b, V c) { return ~((b^a)|(c&b)); }
+V foo_67_2(V a, V b, V c) { return ((c&b)|~a)^b; }
+V foo_67_3(V a, V b, V c) { return ((c&a)|~b)^a; }
+
+V foo_68_1(V a, V b, V c) { return ~c&b; }
+
+V foo_69_1(V a, V b, V c) { return ~((~b&a)|c); }
+V foo_69_2(V a, V b, V c) { return (~a|b)&~c; }
+
+V foo_70_1(V a, V b, V c) { return ((c&a)|b)^c; }
+
+V foo_71_1(V a, V b, V c) { return ~(((c^a)&b)^a); }
+V foo_71_2(V a, V b, V c) { return ((c^a)&b)^~a; }
+V foo_71_3(V a, V b, V c) { return (~a|b)^(c&b); }
+V foo_71_4(V a, V b, V c) { return ((~(c^a))|b)^c; }
+V foo_71_5(V a, V b, V c) { return (~((c^a)&b))^a; }
+V foo_71_6(V a, V b, V c) { return (~b|c)^(b|a); }
+
+V foo_72_1(V a, V b, V c) { return (c^a)&b; }
+
+V foo_73_1(V a, V b, V c) { return ~((((c&a)|b)^a)^c); }
+V foo_73_2(V a, V b, V c) { return (((c&a)|b)^c)^~a; }
+V foo_73_3(V a, V b, V c) { return (~((c&a)|b))^(c^a); }
+V foo_73_4(V a, V b, V c) { return (((c&a)|b)^a)^~c; }
+V foo_73_5(V a, V b, V c) { return ((c&a)|b)^(~(c^a)); }
+V foo_73_6(V a, V b, V c) { return (~(((c&a)|b)^a))^c; }
+V foo_73_7(V a, V b, V c) { return ((c&a)|~b)^(c|a); }
+V foo_73_8(V a, V b, V c) { return (~(((c&a)|b)^c))^a; }
+
+V foo_74_1(V a, V b, V c) { return (c^a)&(c|b); }
+V foo_74_2(V a, V b, V c) { return ((c|b)&a)^c; }
+
+V foo_75_1(V a, V b, V c) { return (~b|c)^a; }
+
+V foo_76_1(V a, V b, V c) { return (~(c&a))&b; }
+
+V foo_77_1(V a, V b, V c) { return ~(((b^a)&(c^a))^c); }
+V foo_77_2(V a, V b, V c) { return ((c^a)&b)|(~(c|a)); }
+V foo_77_3(V a, V b, V c) { return ((c^a)&b)^(~(c|a)); }
+V foo_77_4(V a, V b, V c) { return ((c^a)&(c^b))^~a; }
+V foo_77_5(V a, V b, V c) { return ((b^a)&(c^a))^~c; }
+V foo_77_6(V a, V b, V c) { return ((b^a)|(c^a))^~b; }
+V foo_77_7(V a, V b, V c) { return (~((b^a)|(c^a)))^b; }
+V foo_77_8(V a, V b, V c) { return ((~(c^a))|b)^(c&a); }
+V foo_77_9(V a, V b, V c) { return (~((b^a)&(c^a)))^c; }
+V foo_77_10(V a, V b, V c) { return (~((c^a)&b))^(c|a); }
+V foo_77_11(V a, V b, V c) { return ((c^b)|a)^(~b|c); }
+V foo_77_12(V a, V b, V c) { return (~((c^a)&(c^b)))^a; }
+V foo_77_13(V a, V b, V c) { return ((b^a)|c)^(~b|a); }
+
+V foo_78_1(V a, V b, V c) { return (c&a)^(c|b); }
+V foo_78_2(V a, V b, V c) { return ((b^a)|c)^a; }
+
+V foo_79_1(V a, V b, V c) { return ~((~b|c)&a); }
+V foo_79_2(V a, V b, V c) { return (~c&b)|~a; }
+
+V foo_80_1(V a, V b, V c) { return ~c&a; }
+
+V foo_81_1(V a, V b, V c) { return ~((~a&b)|c); }
+V foo_81_2(V a, V b, V c) { return (~b|a)&~c; }
+
+V foo_82_1(V a, V b, V c) { return ((c&b)|a)^c; }
+
+V foo_83_1(V a, V b, V c) { return ~(((c^b)&a)^b); }
+V foo_83_2(V a, V b, V c) { return ((c^b)&a)^~b; }
+V foo_83_3(V a, V b, V c) { return (~((c^b)&a))^b; }
+V foo_83_4(V a, V b, V c) { return (~b|a)^(c&a); }
+V foo_83_5(V a, V b, V c) { return ((~(c^b))|a)^c; }
+V foo_83_6(V a, V b, V c) { return (~a|c)^(b|a); }
+
+V foo_84_1(V a, V b, V c) { return (b|a)&~c; }
+
+V foo_85_1(V a, V b, V c) { return ~c; }
+
+V foo_86_1(V a, V b, V c) { return (b|a)^c; }
+
+V foo_87_1(V a, V b, V c) { return ~((b|a)&c); }
+
+V foo_88_1(V a, V b, V c) { return (c^a)&(b|a); }
+V foo_88_2(V a, V b, V c) { return ((b|a)&c)^a; }
+
+V foo_89_1(V a, V b, V c) { return (~b|a)^c; }
+
+V foo_90_1(V a, V b, V c) { return c^a; }
+
+V foo_91_1(V a, V b, V c) { return (~(b|a))|(c^a); }
+V foo_91_2(V a, V b, V c) { return (~(c|b))|(c^a); }
+V foo_91_3(V a, V b, V c) { return ((~(c|b))|a)^c; }
+V foo_91_4(V a, V b, V c) { return ((~(b|a))|c)^a; }
+
+V foo_92_1(V a, V b, V c) { return (c&a)^(b|a); }
+V foo_92_2(V a, V b, V c) { return ((c^b)|a)^c; }
+
+V foo_93_1(V a, V b, V c) { return ~((~b|a)&c); }
+V foo_93_2(V a, V b, V c) { return (~a&b)|~c; }
+
+V foo_94_1(V a, V b, V c) { return (~a&b)|(c^a); }
+V foo_94_2(V a, V b, V c) { return (~c&b)|(c^a); }
+V foo_94_3(V a, V b, V c) { return ((~c&b)|a)^c; }
+V foo_94_4(V a, V b, V c) { return ((~a&b)|c)^a; }
+
+V foo_95_1(V a, V b, V c) { return ~(c&a); }
+
+V foo_96_1(V a, V b, V c) { return (c^b)&a; }
+
+V foo_97_1(V a, V b, V c) { return ~(((c|b)^a)|(c&b)); }
+V foo_97_2(V a, V b, V c) { return (~((c&b)|a))^(c^b); }
+V foo_97_3(V a, V b, V c) { return (((c&b)|a)^c)^~b; }
+V foo_97_4(V a, V b, V c) { return (((c&b)|a)^b)^~c; }
+V foo_97_5(V a, V b, V c) { return ((c&b)|~a)^(c|b); }
+V foo_97_6(V a, V b, V c) { return ((c&b)|a)^(~(c^b)); }
+V foo_97_7(V a, V b, V c) { return (~(((c&b)|a)^b))^c; }
+V foo_97_8(V a, V b, V c) { return (~(((c&b)|a)^c))^b; }
+
+V foo_98_1(V a, V b, V c) { return (c^b)&(c|a); }
+V foo_98_2(V a, V b, V c) { return ((c|a)&b)^c; }
+
+V foo_99_1(V a, V b, V c) { return (~a|c)^b; }
+
+V foo_100_1(V a, V b, V c) { return (c^b)&(b|a); }
+V foo_100_2(V a, V b, V c) { return ((b|a)&c)^b; }
+
+V foo_101_1(V a, V b, V c) { return (~a|b)^c; }
+
+V foo_102_1(V a, V b, V c) { return c^b; }
+
+V foo_103_1(V a, V b, V c) { return (~(b|a))|(c^b); }
+V foo_103_2(V a, V b, V c) { return (~(c|a))|(c^b); }
+V foo_103_3(V a, V b, V c) { return ((~(c|a))|b)^c; }
+V foo_103_4(V a, V b, V c) { return ((~(b|a))|c)^b; }
+
+V foo_104_1(V a, V b, V c) { return ((b&a)^c)&(b|a); }
+V foo_104_2(V a, V b, V c) { return ((c&a)^b)&(c|a); }
+V foo_104_3(V a, V b, V c) { return ((c&b)^a)&(c|b); }
+V foo_104_4(V a, V b, V c) { return ((c|b)&a)^(c&b); }
+V foo_104_5(V a, V b, V c) { return ((c|a)&b)^(c&a); }
+V foo_104_6(V a, V b, V c) { return ((b|a)&c)^(b&a); }
+
+V foo_105_1(V a, V b, V c) { return ~((b^a)^c); }
+V foo_105_2(V a, V b, V c) { return (c^b)^~a; }
+V foo_105_3(V a, V b, V c) { return (c^a)^~b; }
+V foo_105_4(V a, V b, V c) { return (b^a)^~c; }
+V foo_105_5(V a, V b, V c) { return (~(c^b))^a; }
+V foo_105_6(V a, V b, V c) { return (~(c^a))^b; }
+V foo_105_7(V a, V b, V c) { return (~(b^a))^c; }
+
+V foo_106_1(V a, V b, V c) { return (b&a)^c; }
+
+V foo_107_1(V a, V b, V c) { return ~(((b|a)&c)^(b^a)); }
+V foo_107_2(V a, V b, V c) { return ((b&a)^c)|(~(b|a)); }
+V foo_107_3(V a, V b, V c) { return ((c^b)&(b|a))^~a; }
+V foo_107_4(V a, V b, V c) { return ((c^a)&(b|a))^~b; }
+V foo_107_5(V a, V b, V c) { return (~((b|a)&c))^(b^a); }
+V foo_107_6(V a, V b, V c) { return (~((c^b)&(b|a)))^a; }
+V foo_107_7(V a, V b, V c) { return (~((c^a)&(b|a)))^b; }
+V foo_107_8(V a, V b, V c) { return ((b|a)&c)^(~(b^a)); }
+V foo_107_9(V a, V b, V c) { return ((~(b|a))|c)^(b&a); }
+
+V foo_108_1(V a, V b, V c) { return (c&a)^b; }
+
+V foo_109_1(V a, V b, V c) { return ~(((b^a)&(c|a))^c); }
+V foo_109_2(V a, V b, V c) { return ((c&a)^b)|(~(c|a)); }
+V foo_109_3(V a, V b, V c) { return ((c^b)&(c|a))^~a; }
+V foo_109_4(V a, V b, V c) { return (~((c|a)&b))^(c^a); }
+V foo_109_5(V a, V b, V c) { return ((b^a)&(c|a))^~c; }
+V foo_109_6(V a, V b, V c) { return (~((c^b)&(c|a)))^a; }
+V foo_109_7(V a, V b, V c) { return ((~(c|a))|b)^(c&a); }
+V foo_109_8(V a, V b, V c) { return ((c|a)&b)^(~(c^a)); }
+V foo_109_9(V a, V b, V c) { return (~((b^a)&(c|a)))^c; }
+
+V foo_110_1(V a, V b, V c) { return (~a&c)|(c^b); }
+V foo_110_2(V a, V b, V c) { return (~a&b)|(c^b); }
+V foo_110_3(V a, V b, V c) { return ((~b|a)&c)^b; }
+V foo_110_4(V a, V b, V c) { return ((~c|a)&b)^c; }
+
+V foo_111_1(V a, V b, V c) { return (c^b)|~a; }
+
+V foo_112_1(V a, V b, V c) { return (~(c&b))&a; }
+
+V foo_113_1(V a, V b, V c) { return ~(((b^a)&(c^b))^c); }
+V foo_113_2(V a, V b, V c) { return ((b^a)|(c^a))^~a; }
+V foo_113_3(V a, V b, V c) { return ((c^b)&a)|(~(c|b)); }
+V foo_113_4(V a, V b, V c) { return ((c^b)&a)^(~(c|b)); }
+V foo_113_5(V a, V b, V c) { return ((b^a)&(c^b))^~c; }
+V foo_113_6(V a, V b, V c) { return ((c^a)&(c^b))^~b; }
+V foo_113_7(V a, V b, V c) { return (~((b^a)|(c^a)))^a; }
+V foo_113_8(V a, V b, V c) { return ((~(c^b))|a)^(c&b); }
+V foo_113_9(V a, V b, V c) { return (~((c^b)&a))^(c|b); }
+V foo_113_10(V a, V b, V c) { return (~((b^a)&(c^b)))^c; }
+V foo_113_11(V a, V b, V c) { return ((c^a)|b)^(~a|c); }
+V foo_113_12(V a, V b, V c) { return (~((c^a)&(c^b)))^b; }
+V foo_113_13(V a, V b, V c) { return ((b^a)|c)^(~a|b); }
+
+V foo_114_1(V a, V b, V c) { return (c&b)^(c|a); }
+V foo_114_2(V a, V b, V c) { return ((b^a)|c)^b; }
+
+V foo_115_1(V a, V b, V c) { return ~((~a|c)&b); }
+V foo_115_2(V a, V b, V c) { return (~c&a)|~b; }
+
+V foo_116_1(V a, V b, V c) { return (c&b)^(b|a); }
+V foo_116_2(V a, V b, V c) { return ((c^a)|b)^c; }
+
+V foo_117_1(V a, V b, V c) { return ~((~a|b)&c); }
+V foo_117_2(V a, V b, V c) { return (~b&a)|~c; }
+
+V foo_118_1(V a, V b, V c) { return (~b&a)|(c^b); }
+V foo_118_2(V a, V b, V c) { return (~c&a)|(c^b); }
+V foo_118_3(V a, V b, V c) { return ((~c&a)|b)^c; }
+V foo_118_4(V a, V b, V c) { return ((~b&a)|c)^b; }
+
+V foo_119_1(V a, V b, V c) { return ~(c&b); }
+
+V foo_120_1(V a, V b, V c) { return (c&b)^a; }
+
+V foo_121_1(V a, V b, V c) { return ~(((b^a)&(c|b))^c); }
+V foo_121_2(V a, V b, V c) { return ((c&b)^a)|(~(c|b)); }
+V foo_121_3(V a, V b, V c) { return (~((c|b)&a))^(c^b); }
+V foo_121_4(V a, V b, V c) { return ((b^a)&(c|b))^~c; }
+V foo_121_5(V a, V b, V c) { return ((c^a)&(c|b))^~b; }
+V foo_121_6(V a, V b, V c) { return ((~(c|b))|a)^(c&b); }
+V foo_121_7(V a, V b, V c) { return ((c|b)&a)^(~(c^b)); }
+V foo_121_8(V a, V b, V c) { return (~((b^a)&(c|b)))^c; }
+V foo_121_9(V a, V b, V c) { return (~((c^a)&(c|b)))^b; }
+
+V foo_122_1(V a, V b, V c) { return (~b&c)|(c^a); }
+V foo_122_2(V a, V b, V c) { return (~b&a)|(c^a); }
+V foo_122_3(V a, V b, V c) { return ((~a|b)&c)^a; }
+V foo_122_4(V a, V b, V c) { return ((~c|b)&a)^c; }
+
+V foo_123_1(V a, V b, V c) { return (c^a)|~b; }
+
+V foo_124_1(V a, V b, V c) { return (~c&b)|(b^a); }
+V foo_124_2(V a, V b, V c) { return (~c&a)|(b^a); }
+V foo_124_3(V a, V b, V c) { return ((~a|c)&b)^a; }
+V foo_124_4(V a, V b, V c) { return ((~b|c)&a)^b; }
+
+V foo_125_1(V a, V b, V c) { return (b^a)|~c; }
+
+V foo_126_1(V a, V b, V c) { return (b^a)|(c^a); }
+V foo_126_2(V a, V b, V c) { return (b^a)|(c^b); }
+V foo_126_3(V a, V b, V c) { return (c^a)|(c^b); }
+
+V foo_127_1(V a, V b, V c) { return ~((c&b)&a); }
+
+V foo_128_1(V a, V b, V c) { return (c&b)&a; }
+V foo_128_2(V a, V b, V c) { return (c&a)&b; }
+V foo_128_3(V a, V b, V c) { return (b&a)&c; }
+
+V foo_129_1(V a, V b, V c) { return ~((b^a)|(c^a)); }
+
+V foo_130_1(V a, V b, V c) { return (~(b^a))&c; }
+
+V foo_131_1(V a, V b, V c) { return ~((~c&b)|(b^a)); }
+V foo_131_2(V a, V b, V c) { return ((~a|c)&b)^~a; }
+V foo_131_3(V a, V b, V c) { return ((~b|c)&a)^~b; }
+V foo_131_4(V a, V b, V c) { return (~((~b|c)&a))^b; }
+V foo_131_5(V a, V b, V c) { return (~((~a|c)&b))^a; }
+V foo_131_6(V a, V b, V c) { return (~a|c)&(~(b^a)); }
+V foo_131_7(V a, V b, V c) { return (~b|c)&(~(b^a)); }
+
+V foo_132_1(V a, V b, V c) { return (~(c^a))&b; }
+
+V foo_133_1(V a, V b, V c) { return ~((~b&c)|(c^a)); }
+V foo_133_2(V a, V b, V c) { return ((~a|b)&c)^~a; }
+V foo_133_3(V a, V b, V c) { return (~((~c|b)&a))^c; }
+V foo_133_4(V a, V b, V c) { return ((~c|b)&a)^~c; }
+V foo_133_5(V a, V b, V c) { return (~((~a|b)&c))^a; }
+V foo_133_6(V a, V b, V c) { return (~(c^a))&(~a|b); }
+V foo_133_7(V a, V b, V c) { return (~(c^a))&(~c|b); }
+
+V foo_134_1(V a, V b, V c) { return ((b^a)&(c|b))^c; }
+V foo_134_2(V a, V b, V c) { return ((c^a)&(c|b))^b; }
+V foo_134_3(V a, V b, V c) { return ((c|b)&a)^(c^b); }
+V foo_134_4(V a, V b, V c) { return ((b^a)^c)&(c|b); }
+
+V foo_135_1(V a, V b, V c) { return ~((c&b)^a); }
+V foo_135_2(V a, V b, V c) { return (c&b)^~a; }
+V foo_135_3(V a, V b, V c) { return (~(c&b))^a; }
+
+V foo_136_1(V a, V b, V c) { return c&b; }
+
+V foo_137_1(V a, V b, V c) { return ~((~b&a)|(c^b)); }
+V foo_137_2(V a, V b, V c) { return (~((~c&a)|b))^c; }
+V foo_137_3(V a, V b, V c) { return ((~b&a)|c)^~b; }
+V foo_137_4(V a, V b, V c) { return (~((~b&a)|c))^b; }
+V foo_137_5(V a, V b, V c) { return ((~c&a)|b)^~c; }
+V foo_137_6(V a, V b, V c) { return (~(c^b))&(~a|c); }
+V foo_137_7(V a, V b, V c) { return (~(c^b))&(~a|b); }
+
+V foo_138_1(V a, V b, V c) { return (~a|b)&c; }
+
+V foo_139_1(V a, V b, V c) { return ~((c&b)^(b|a)); }
+V foo_139_2(V a, V b, V c) { return (~(b|a))|(c&b); }
+V foo_139_3(V a, V b, V c) { return (~(b|a))^(c&b); }
+V foo_139_4(V a, V b, V c) { return (~((c^a)|b))^c; }
+V foo_139_5(V a, V b, V c) { return ((c^a)|b)^~c; }
+V foo_139_6(V a, V b, V c) { return (~(c&b))^(b|a); }
+V foo_139_7(V a, V b, V c) { return ((c^a)|~b)^a; }
+
+V foo_140_1(V a, V b, V c) { return (~a|c)&b; }
+
+V foo_141_1(V a, V b, V c) { return ~((c&b)^(c|a)); }
+V foo_141_2(V a, V b, V c) { return (~(c|a))|(c&b); }
+V foo_141_3(V a, V b, V c) { return (~(c|a))^(c&b); }
+V foo_141_4(V a, V b, V c) { return ((b^a)|c)^~b; }
+V foo_141_5(V a, V b, V c) { return (~((b^a)|c))^b; }
+V foo_141_6(V a, V b, V c) { return (~(c&b))^(c|a); }
+V foo_141_7(V a, V b, V c) { return ((b^a)|~c)^a; }
+
+V foo_142_1(V a, V b, V c) { return ((b^a)&(c^b))^c; }
+V foo_142_2(V a, V b, V c) { return ((c^a)&(c^b))^b; }
+V foo_142_3(V a, V b, V c) { return ((c^b)&a)^(c|b); }
+V foo_142_4(V a, V b, V c) { return ((b^a)|(c^a))^a; }
+
+V foo_143_1(V a, V b, V c) { return (c&b)|~a; }
+
+V foo_144_1(V a, V b, V c) { return (~(c^b))&a; }
+
+V foo_145_1(V a, V b, V c) { return ~((~a&c)|(c^b)); }
+V foo_145_2(V a, V b, V c) { return ((~b|a)&c)^~b; }
+V foo_145_3(V a, V b, V c) { return (~((~c|a)&b))^c; }
+V foo_145_4(V a, V b, V c) { return ((~c|a)&b)^~c; }
+V foo_145_5(V a, V b, V c) { return (~((~b|a)&c))^b; }
+V foo_145_6(V a, V b, V c) { return (~(c^b))&(~b|a); }
+V foo_145_7(V a, V b, V c) { return (~(c^b))&(~c|a); }
+
+V foo_146_1(V a, V b, V c) { return ((b^a)&(c|a))^c; }
+V foo_146_2(V a, V b, V c) { return ((c|a)&b)^(c^a); }
+V foo_146_3(V a, V b, V c) { return ((c^b)&(c|a))^a; }
+V foo_146_4(V a, V b, V c) { return ((b^a)^c)&(c|a); }
+
+V foo_147_1(V a, V b, V c) { return ~((c&a)^b); }
+V foo_147_2(V a, V b, V c) { return (c&a)^~b; }
+V foo_147_3(V a, V b, V c) { return (~(c&a))^b; }
+
+V foo_148_1(V a, V b, V c) { return ((b|a)&c)^(b^a); }
+V foo_148_2(V a, V b, V c) { return ((c^a)&(b|a))^b; }
+V foo_148_3(V a, V b, V c) { return ((c^b)&(b|a))^a; }
+V foo_148_4(V a, V b, V c) { return ((b^a)^c)&(b|a); }
+
+V foo_149_1(V a, V b, V c) { return ~((b&a)^c); }
+V foo_149_2(V a, V b, V c) { return (~(b&a))^c; }
+V foo_149_3(V a, V b, V c) { return (b&a)^~c; }
+
+V foo_150_1(V a, V b, V c) { return (b^a)^c; }
+V foo_150_2(V a, V b, V c) { return (c^a)^b; }
+V foo_150_3(V a, V b, V c) { return (c^b)^a; }
+
+V foo_151_1(V a, V b, V c) { return ~(((b&a)^c)&(b|a)); }
+V foo_151_2(V a, V b, V c) { return ((b^a)^c)|(~(b|a)); }
+V foo_151_3(V a, V b, V c) { return ((b^a)^c)|(~(c|a)); }
+V foo_151_4(V a, V b, V c) { return ((b^a)^c)|(~(c|b)); }
+V foo_151_5(V a, V b, V c) { return (~((c|b)&a))^(c&b); }
+V foo_151_6(V a, V b, V c) { return (~((c|a)&b))^(c&a); }
+V foo_151_7(V a, V b, V c) { return ((~(b|a))|c)^(b^a); }
+V foo_151_8(V a, V b, V c) { return ((~(c|a))|(b^a))^c; }
+V foo_151_9(V a, V b, V c) { return ((b|a)&c)^(~(b&a)); }
+V foo_151_10(V a, V b, V c) { return (~((b|a)&c))^(b&a); }
+V foo_151_11(V a, V b, V c) { return ((~(c|a))|b)^(c^a); }
+V foo_151_12(V a, V b, V c) { return ((~(b|a))|(c^a))^b; }
+V foo_151_13(V a, V b, V c) { return ((c|a)&b)^(~(c&a)); }
+V foo_151_14(V a, V b, V c) { return ((~(c|b))|a)^(c^b); }
+V foo_151_15(V a, V b, V c) { return ((~(b|a))|(c^b))^a; }
+V foo_151_16(V a, V b, V c) { return ((c|b)&a)^(~(c&b)); }
+
+V foo_152_1(V a, V b, V c) { return ((c|a)&~b)^c; }
+V foo_152_2(V a, V b, V c) { return ((b|a)&~c)^b; }
+V foo_152_3(V a, V b, V c) { return (~(c^b))&(c|a); }
+V foo_152_4(V a, V b, V c) { return (~(c^b))&(b|a); }
+
+V foo_153_1(V a, V b, V c) { return ~(c^b); }
+V foo_153_2(V a, V b, V c) { return ~b^c; }
+V foo_153_3(V a, V b, V c) { return ~c^b; }
+
+V foo_154_1(V a, V b, V c) { return (~b&a)^c; }
+
+V foo_155_1(V a, V b, V c) { return ~((c^b)&(b|a)); }
+V foo_155_2(V a, V b, V c) { return ((b|a)&c)^~b; }
+V foo_155_3(V a, V b, V c) { return (~((b|a)&c))^b; }
+
+V foo_156_1(V a, V b, V c) { return (~c&a)^b; }
+
+V foo_157_1(V a, V b, V c) { return ~((c^b)&(c|a)); }
+V foo_157_2(V a, V b, V c) { return (~((c|a)&b))^c; }
+V foo_157_3(V a, V b, V c) { return ((c|a)&b)^~c; }
+
+V foo_158_1(V a, V b, V c) { return ((c|b)^a)|(c&b); }
+V foo_158_2(V a, V b, V c) { return (((c&b)|a)^b)^c; }
+V foo_158_3(V a, V b, V c) { return (((c&b)|a)^c)^b; }
+V foo_158_4(V a, V b, V c) { return ((c&b)|a)^(c^b); }
+V foo_158_5(V a, V b, V c) { return ((b^a)^c)|(c&b); }
+
+V foo_159_1(V a, V b, V c) { return ~((c^b)&a); }
+
+V foo_160_1(V a, V b, V c) { return c&a; }
+
+V foo_161_1(V a, V b, V c) { return ~((~a&b)|(c^a)); }
+V foo_161_2(V a, V b, V c) { return (~((~c&b)|a))^c; }
+V foo_161_3(V a, V b, V c) { return ((~a&b)|c)^~a; }
+V foo_161_4(V a, V b, V c) { return (~((~a&b)|c))^a; }
+V foo_161_5(V a, V b, V c) { return ((~c&b)|a)^~c; }
+V foo_161_6(V a, V b, V c) { return (~(c^a))&(~b|c); }
+V foo_161_7(V a, V b, V c) { return (~(c^a))&(~b|a); }
+
+V foo_162_1(V a, V b, V c) { return (~b|a)&c; }
+
+V foo_163_1(V a, V b, V c) { return ~((c&a)^(b|a)); }
+V foo_163_2(V a, V b, V c) { return (~(b|a))|(c&a); }
+V foo_163_3(V a, V b, V c) { return (~(b|a))^(c&a); }
+V foo_163_4(V a, V b, V c) { return (~((c^b)|a))^c; }
+V foo_163_5(V a, V b, V c) { return ((c^b)|a)^~c; }
+V foo_163_6(V a, V b, V c) { return (~(c&a))^(b|a); }
+V foo_163_7(V a, V b, V c) { return ((c^b)|~a)^b; }
+
+V foo_164_1(V a, V b, V c) { return ((c|b)&~a)^c; }
+V foo_164_2(V a, V b, V c) { return ((b|a)&~c)^a; }
+V foo_164_3(V a, V b, V c) { return (~(c^a))&(c|b); }
+V foo_164_4(V a, V b, V c) { return (~(c^a))&(b|a); }
+
+V foo_165_1(V a, V b, V c) { return ~(c^a); }
+V foo_165_2(V a, V b, V c) { return ~a^c; }
+V foo_165_3(V a, V b, V c) { return ~c^a; }
+
+V foo_166_1(V a, V b, V c) { return (~a&b)^c; }
+
+V foo_167_1(V a, V b, V c) { return ~((c^a)&(b|a)); }
+V foo_167_2(V a, V b, V c) { return ((b|a)&c)^~a; }
+V foo_167_3(V a, V b, V c) { return (~((b|a)&c))^a; }
+
+V foo_168_1(V a, V b, V c) { return (b|a)&c; }
+
+V foo_169_1(V a, V b, V c) { return ~((b|a)^c); }
+V foo_169_2(V a, V b, V c) { return (~(b|a))^c; }
+V foo_169_3(V a, V b, V c) { return (b|a)^~c; }
+
+V foo_170_1(V a, V b, V c) { return c; }
+
+V foo_171_1(V a, V b, V c) { return (~(b|a))|c; }
+
+V foo_172_1(V a, V b, V c) { return ((c^b)&a)^b; }
+
+V foo_173_1(V a, V b, V c) { return ~(((c&b)|a)^c); }
+V foo_173_2(V a, V b, V c) { return (~((c&b)|a))^c; }
+V foo_173_3(V a, V b, V c) { return ((c&b)|a)^~c; }
+V foo_173_4(V a, V b, V c) { return (~(c^a))|(c&b); }
+
+V foo_174_1(V a, V b, V c) { return (~a&b)|c; }
+
+V foo_175_1(V a, V b, V c) { return ~a|c; }
+
+V foo_176_1(V a, V b, V c) { return (~b|c)&a; }
+
+V foo_177_1(V a, V b, V c) { return ~((c&a)^(c|b)); }
+V foo_177_2(V a, V b, V c) { return ((b^a)|c)^~a; }
+V foo_177_3(V a, V b, V c) { return (~(c|b))|(c&a); }
+V foo_177_4(V a, V b, V c) { return (~(c|b))^(c&a); }
+V foo_177_5(V a, V b, V c) { return (~((b^a)|c))^a; }
+V foo_177_6(V a, V b, V c) { return (~(c&a))^(c|b); }
+V foo_177_7(V a, V b, V c) { return ((b^a)|~c)^b; }
+
+V foo_178_1(V a, V b, V c) { return ((b^a)&(c^a))^c; }
+V foo_178_2(V a, V b, V c) { return ((c^a)&(c^b))^a; }
+V foo_178_3(V a, V b, V c) { return ((c^a)&b)^(c|a); }
+V foo_178_4(V a, V b, V c) { return ((b^a)|(c^a))^b; }
+
+V foo_179_1(V a, V b, V c) { return (c&a)|~b; }
+
+V foo_180_1(V a, V b, V c) { return (~c&b)^a; }
+
+V foo_181_1(V a, V b, V c) { return ~((c^a)&(c|b)); }
+V foo_181_2(V a, V b, V c) { return (~((c|b)&a))^c; }
+V foo_181_3(V a, V b, V c) { return ((c|b)&a)^~c; }
+
+V foo_182_1(V a, V b, V c) { return (((c&a)|b)^a)^c; }
+V foo_182_2(V a, V b, V c) { return ((c|a)^b)|(c&a); }
+V foo_182_3(V a, V b, V c) { return (((c&a)|b)^c)^a; }
+V foo_182_4(V a, V b, V c) { return ((c&a)|b)^(c^a); }
+V foo_182_5(V a, V b, V c) { return ((b^a)^c)|(c&a); }
+
+V foo_183_1(V a, V b, V c) { return ~((c^a)&b); }
+
+V foo_184_1(V a, V b, V c) { return ((c^a)&b)^a; }
+
+V foo_185_1(V a, V b, V c) { return ~(((c&a)|b)^c); }
+V foo_185_2(V a, V b, V c) { return (~((c&a)|b))^c; }
+V foo_185_3(V a, V b, V c) { return ((c&a)|b)^~c; }
+V foo_185_4(V a, V b, V c) { return (~(c^b))|(c&a); }
+
+V foo_186_1(V a, V b, V c) { return (~b&a)|c; }
+
+V foo_187_1(V a, V b, V c) { return ~b|c; }
+
+V foo_188_1(V a, V b, V c) { return (b^a)|(c&b); }
+V foo_188_2(V a, V b, V c) { return (b^a)|(c&a); }
+
+V foo_189_1(V a, V b, V c) { return ~((c^a)&(c^b)); }
+V foo_189_2(V a, V b, V c) { return (~(c^b))|(b^a); }
+V foo_189_3(V a, V b, V c) { return (~(c^a))|(b^a); }
+
+V foo_190_1(V a, V b, V c) { return (b^a)|c; }
+
+V foo_191_1(V a, V b, V c) { return (~(b&a))|c; }
+
+V foo_192_1(V a, V b, V c) { return b&a; }
+
+V foo_193_1(V a, V b, V c) { return ~((~a&c)|(b^a)); }
+V foo_193_2(V a, V b, V c) { return (~((~b&c)|a))^b; }
+V foo_193_3(V a, V b, V c) { return ((~a&c)|b)^~a; }
+V foo_193_4(V a, V b, V c) { return (~((~a&c)|b))^a; }
+V foo_193_5(V a, V b, V c) { return ((~b&c)|a)^~b; }
+V foo_193_6(V a, V b, V c) { return (~(b^a))&(~c|b); }
+V foo_193_7(V a, V b, V c) { return (~(b^a))&(~c|a); }
+
+V foo_194_1(V a, V b, V c) { return ((c|b)&~a)^b; }
+V foo_194_2(V a, V b, V c) { return ((c|a)&~b)^a; }
+V foo_194_3(V a, V b, V c) { return (~(b^a))&(c|b); }
+V foo_194_4(V a, V b, V c) { return (~(b^a))&(c|a); }
+
+V foo_195_1(V a, V b, V c) { return ~(b^a); }
+V foo_195_2(V a, V b, V c) { return ~a^b; }
+V foo_195_3(V a, V b, V c) { return ~b^a; }
+
+V foo_196_1(V a, V b, V c) { return (~c|a)&b; }
+
+V foo_197_1(V a, V b, V c) { return ~((b&a)^(c|a)); }
+V foo_197_2(V a, V b, V c) { return (~(c|a))|(b&a); }
+V foo_197_3(V a, V b, V c) { return (~(c|a))^(b&a); }
+V foo_197_4(V a, V b, V c) { return (~((c^b)|a))^b; }
+V foo_197_5(V a, V b, V c) { return ((c^b)|a)^~b; }
+V foo_197_6(V a, V b, V c) { return (~(b&a))^(c|a); }
+V foo_197_7(V a, V b, V c) { return ((c^b)|~a)^c; }
+
+V foo_198_1(V a, V b, V c) { return (~a&c)^b; }
+
+V foo_199_1(V a, V b, V c) { return ~((b^a)&(c|a)); }
+V foo_199_2(V a, V b, V c) { return ((c|a)&b)^~a; }
+V foo_199_3(V a, V b, V c) { return (~((c|a)&b))^a; }
+
+V foo_200_1(V a, V b, V c) { return (c|a)&b; }
+
+V foo_201_1(V a, V b, V c) { return ~((c|a)^b); }
+V foo_201_2(V a, V b, V c) { return (~(c|a))^b; }
+V foo_201_3(V a, V b, V c) { return (c|a)^~b; }
+
+V foo_202_1(V a, V b, V c) { return ((c^b)&a)^c; }
+
+V foo_203_1(V a, V b, V c) { return ~(((c&b)|a)^b); }
+V foo_203_2(V a, V b, V c) { return (~((c&b)|a))^b; }
+V foo_203_3(V a, V b, V c) { return ((c&b)|a)^~b; }
+V foo_203_4(V a, V b, V c) { return (~(b^a))|(c&b); }
+
+V foo_204_1(V a, V b, V c) { return b; }
+
+V foo_205_1(V a, V b, V c) { return (~(c|a))|b; }
+
+V foo_206_1(V a, V b, V c) { return (~a&c)|b; }
+
+V foo_207_1(V a, V b, V c) { return ~a|b; }
+
+V foo_208_1(V a, V b, V c) { return (~c|b)&a; }
+
+V foo_209_1(V a, V b, V c) { return ~((b&a)^(c|b)); }
+V foo_209_2(V a, V b, V c) { return ((c^a)|b)^~a; }
+V foo_209_3(V a, V b, V c) { return (~(c|b))|(b&a); }
+V foo_209_4(V a, V b, V c) { return (~(c|b))^(b&a); }
+V foo_209_5(V a, V b, V c) { return (~((c^a)|b))^a; }
+V foo_209_6(V a, V b, V c) { return (~(b&a))^(c|b); }
+V foo_209_7(V a, V b, V c) { return ((c^a)|~b)^c; }
+
+V foo_210_1(V a, V b, V c) { return (~b&c)^a; }
+
+V foo_211_1(V a, V b, V c) { return ~((b^a)&(c|b)); }
+V foo_211_2(V a, V b, V c) { return (~((c|b)&a))^b; }
+V foo_211_3(V a, V b, V c) { return ((c|b)&a)^~b; }
+
+V foo_212_1(V a, V b, V c) { return ((b^a)&(c^a))^b; }
+V foo_212_2(V a, V b, V c) { return ((b^a)&(c^b))^a; }
+V foo_212_3(V a, V b, V c) { return ((b^a)&c)^(b|a); }
+V foo_212_4(V a, V b, V c) { return ((b^a)|(c^a))^c; }
+
+V foo_213_1(V a, V b, V c) { return (b&a)|~c; }
+
+V foo_214_1(V a, V b, V c) { return (((b&a)|c)^a)^b; }
+V foo_214_2(V a, V b, V c) { return (((b&a)|c)^b)^a; }
+V foo_214_3(V a, V b, V c) { return ((b&a)|c)^(b^a); }
+V foo_214_4(V a, V b, V c) { return ((b|a)^c)|(b&a); }
+V foo_214_5(V a, V b, V c) { return ((b^a)^c)|(b&a); }
+
+V foo_215_1(V a, V b, V c) { return ~((b^a)&c); }
+
+V foo_216_1(V a, V b, V c) { return ((b^a)&c)^a; }
+
+V foo_217_1(V a, V b, V c) { return ~(((b&a)|c)^b); }
+V foo_217_2(V a, V b, V c) { return (~((b&a)|c))^b; }
+V foo_217_3(V a, V b, V c) { return ((b&a)|c)^~b; }
+V foo_217_4(V a, V b, V c) { return (~(c^b))|(b&a); }
+
+V foo_218_1(V a, V b, V c) { return (c^a)|(c&b); }
+V foo_218_2(V a, V b, V c) { return (c^a)|(b&a); }
+
+V foo_219_1(V a, V b, V c) { return ~((b^a)&(c^b)); }
+V foo_219_2(V a, V b, V c) { return (~(c^b))|(c^a); }
+V foo_219_3(V a, V b, V c) { return (~(b^a))|(c^a); }
+
+V foo_220_1(V a, V b, V c) { return (~c&a)|b; }
+
+V foo_221_1(V a, V b, V c) { return ~c|b; }
+
+V foo_222_1(V a, V b, V c) { return (c^a)|b; }
+
+V foo_223_1(V a, V b, V c) { return (~(c&a))|b; }
+
+V foo_224_1(V a, V b, V c) { return (c|b)&a; }
+
+V foo_225_1(V a, V b, V c) { return ~((c|b)^a); }
+V foo_225_2(V a, V b, V c) { return (c|b)^~a; }
+V foo_225_3(V a, V b, V c) { return (~(c|b))^a; }
+
+V foo_226_1(V a, V b, V c) { return ((c^a)&b)^c; }
+
+V foo_227_1(V a, V b, V c) { return ~(((c&a)|b)^a); }
+V foo_227_2(V a, V b, V c) { return ((c&a)|b)^~a; }
+V foo_227_3(V a, V b, V c) { return (~((c&a)|b))^a; }
+V foo_227_4(V a, V b, V c) { return (~(b^a))|(c&a); }
+
+V foo_228_1(V a, V b, V c) { return ((b^a)&c)^b; }
+
+V foo_229_1(V a, V b, V c) { return ~(((b&a)|c)^a); }
+V foo_229_2(V a, V b, V c) { return ((b&a)|c)^~a; }
+V foo_229_3(V a, V b, V c) { return (~((b&a)|c))^a; }
+V foo_229_4(V a, V b, V c) { return (~(c^a))|(b&a); }
+
+V foo_230_1(V a, V b, V c) { return (c^b)|(c&a); }
+V foo_230_2(V a, V b, V c) { return (c^b)|(b&a); }
+
+V foo_231_1(V a, V b, V c) { return ~((b^a)&(c^a)); }
+V foo_231_2(V a, V b, V c) { return (~(c^a))|(c^b); }
+V foo_231_3(V a, V b, V c) { return (~(b^a))|(c^b); }
+
+V foo_232_1(V a, V b, V c) { return ((b^a)&(c^a))^a; }
+V foo_232_2(V a, V b, V c) { return ((b^a)&(c^b))^b; }
+V foo_232_3(V a, V b, V c) { return ((b^a)&c)|(b&a); }
+V foo_232_4(V a, V b, V c) { return ((b^a)&c)^(b&a); }
+V foo_232_5(V a, V b, V c) { return ((c^a)&(c^b))^c; }
+V foo_232_6(V a, V b, V c) { return ((c^a)&b)|(c&a); }
+V foo_232_7(V a, V b, V c) { return ((c^a)&b)^(c&a); }
+V foo_232_8(V a, V b, V c) { return ((c^b)&a)|(c&b); }
+V foo_232_9(V a, V b, V c) { return ((c^b)&a)^(c&b); }
+V foo_232_10(V a, V b, V c) { return ((c|b)&a)|(c&b); }
+V foo_232_11(V a, V b, V c) { return ((c|a)&b)|(c&a); }
+V foo_232_12(V a, V b, V c) { return ((b|a)&c)|(b&a); }
+V foo_232_13(V a, V b, V c) { return ((b&a)|c)&(b|a); }
+V foo_232_14(V a, V b, V c) { return ((c&a)|b)&(c|a); }
+V foo_232_15(V a, V b, V c) { return ((c&b)|a)&(c|b); }
+
+V foo_233_1(V a, V b, V c) { return ~(((b^a)|(c&b))^c); }
+V foo_233_2(V a, V b, V c) { return ((b&a)|c)^(~(b|a)); }
+V foo_233_3(V a, V b, V c) { return ((c&a)|b)^(~(c|a)); }
+V foo_233_4(V a, V b, V c) { return (~((c&b)|a))^(c|b); }
+V foo_233_5(V a, V b, V c) { return ((c^b)|(c&a))^~a; }
+V foo_233_6(V a, V b, V c) { return ((c&b)|a)^(~(c|b)); }
+V foo_233_7(V a, V b, V c) { return (~((c&a)|b))^(c|a); }
+V foo_233_8(V a, V b, V c) { return (~((b&a)|c))^(b|a); }
+V foo_233_9(V a, V b, V c) { return (~((c^b)|(c&a)))^a; }
+V foo_233_10(V a, V b, V c) { return (~((c^a)|(c&b)))^b; }
+V foo_233_11(V a, V b, V c) { return ((c^a)|(c&b))^~b; }
+V foo_233_12(V a, V b, V c) { return ((b&a)|~c)^(b^a); }
+V foo_233_13(V a, V b, V c) { return (~((b^a)|(c&b)))^c; }
+V foo_233_14(V a, V b, V c) { return ((b^a)|(c&b))^~c; }
+V foo_233_15(V a, V b, V c) { return ((c&a)|~b)^(c^a); }
+V foo_233_16(V a, V b, V c) { return ((c&b)|~a)^(c^b); }
+V foo_233_17(V a, V b, V c) { return (~((b^a)^c))|(c&b); }
+V foo_233_18(V a, V b, V c) { return (~((b^a)^c))|(c&a); }
+V foo_233_19(V a, V b, V c) { return (~((b^a)^c))|(b&a); }
+V foo_233_20(V a, V b, V c) { return (~((c|b)^a))|(c&b); }
+V foo_233_21(V a, V b, V c) { return (~((c|a)^b))|(c&a); }
+V foo_233_22(V a, V b, V c) { return (~((b|a)^c))|(b&a); }
+
+V foo_234_1(V a, V b, V c) { return (b&a)|c; }
+
+V foo_235_1(V a, V b, V c) { return (~(b^a))|c; }
+
+V foo_236_1(V a, V b, V c) { return (c&a)|b; }
+
+V foo_237_1(V a, V b, V c) { return (~(c^a))|b; }
+
+V foo_238_1(V a, V b, V c) { return c|b; }
+
+V foo_239_1(V a, V b, V c) { return (c|b)|~a; }
+V foo_239_2(V a, V b, V c) { return (~a|b)|c; }
+V foo_239_3(V a, V b, V c) { return (~a|c)|b; }
+
+V foo_240_1(V a, V b, V c) { return a; }
+
+V foo_241_1(V a, V b, V c) { return (~(c|b))|a; }
+
+V foo_242_1(V a, V b, V c) { return (~b&c)|a; }
+
+V foo_243_1(V a, V b, V c) { return ~b|a; }
+
+V foo_244_1(V a, V b, V c) { return (~c&b)|a; }
+
+V foo_245_1(V a, V b, V c) { return ~c|a; }
+
+V foo_246_1(V a, V b, V c) { return (c^b)|a; }
+
+V foo_247_1(V a, V b, V c) { return (~(c&b))|a; }
+
+V foo_248_1(V a, V b, V c) { return (c&b)|a; }
+
+V foo_249_1(V a, V b, V c) { return (~(c^b))|a; }
+
+V foo_250_1(V a, V b, V c) { return c|a; }
+
+V foo_251_1(V a, V b, V c) { return (c|a)|~b; }
+V foo_251_2(V a, V b, V c) { return (~b|a)|c; }
+V foo_251_3(V a, V b, V c) { return (~b|c)|a; }
+
+V foo_252_1(V a, V b, V c) { return b|a; }
+
+V foo_253_1(V a, V b, V c) { return (b|a)|~c; }
+V foo_253_2(V a, V b, V c) { return (~c|a)|b; }
+V foo_253_3(V a, V b, V c) { return (~c|b)|a; }
+
+V foo_254_1(V a, V b, V c) { return (b|a)|c; }
+V foo_254_2(V a, V b, V c) { return (c|a)|b; }
+V foo_254_3(V a, V b, V c) { return (c|b)|a; }
+
+V foo_255_1(V a, V b, V c) { return (V){~0,~0,~0,~0}; }
+
+/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]" 679 } } */
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-1.c
index ef30246..8e5d22f 100644
--- a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-1.c
@@ -1,6 +1,5 @@ 
 /* { dg-do compile } */
 /* { dg-options "-mavx512f -O2" } */
-/* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
 /* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
 
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-3.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-3.c
new file mode 100644
index 0000000..fb943da
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-3.c
@@ -0,0 +1,9 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=x86-64-v4" } */
+
+#include <immintrin.h>
+__m256i
+foo2 (__m256i** a, __m256i b)
+{
+  return ~(**a);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogd-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogd-1.c
index 045a266..dd53563 100644
--- a/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogd-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogd-1.c
@@ -1,7 +1,5 @@ 
 /* { dg-do compile } */
 /* { dg-options "-mavx512vl -O2" } */
-/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
-/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
 /* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogq-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogq-1.c
index 3a6707c..31fec3e 100644
--- a/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogq-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogq-1.c
@@ -1,7 +1,5 @@ 
 /* { dg-do compile } */
 /* { dg-options "-mavx512vl -O2" } */
-/* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
-/* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
 /* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr100711-4.c b/gcc/testsuite/gcc.target/i386/pr100711-4.c
index 3ca524f..26152d6 100644
--- a/gcc/testsuite/gcc.target/i386/pr100711-4.c
+++ b/gcc/testsuite/gcc.target/i386/pr100711-4.c
@@ -37,6 +37,6 @@  v8di foo_v8di (long long a, v8di b)
     return (__extension__ (v8di) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) | b;
 }
 
-/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$0xbb" 4 { target { ! ia32 } } } } */
-/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$0xbb" 2 { target { ia32 } } } } */
+/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$207" 4 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\\\$207" 2 { target { ia32 } } } } */
 /* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$0xdd" 2 { target { ia32 } } } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr100711-5.c b/gcc/testsuite/gcc.target/i386/pr100711-5.c
index 161fbfc..820bed8 100644
--- a/gcc/testsuite/gcc.target/i386/pr100711-5.c
+++ b/gcc/testsuite/gcc.target/i386/pr100711-5.c
@@ -37,4 +37,7 @@  v8di foo_v8di (long long a, v8di b)
     return (__extension__ (v8di) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) ^ b;
 }
 
-/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$0x99" 4 } } */
+/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$195" 4 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\\\$195" 2 { target { ia32 } } } } */
+/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$0x99" 2 { target { ia32 } } } } */
+