Hi! For VECTOR_BOOLEAN_TYPE_P vectype the element type can have different precision from TYPE_SIZE, which is what we use for the bitsize. The following patch uses then some other integral type of that precision before it is actually converted to lhs_type (boolean_type_node).
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-12-05 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/78675 * tree-vect-loop.c (vectorizable_live_operation): For VECTOR_BOOLEAN_TYPE_P vectype use integral type with bitsize precision instead of TREE_TYPE (vectype) for the BIT_FIELD_REF. * gcc.target/i386/pr78675-1.c: New test. * gcc.target/i386/pr78675-2.c: New test. --- gcc/tree-vect-loop.c.jj 2016-11-16 18:51:58.000000000 +0100 +++ gcc/tree-vect-loop.c 2016-12-05 10:58:59.175857316 +0100 @@ -6601,8 +6601,10 @@ vectorizable_live_operation (gimple *stm /* Create a new vectorized stmt for the uses of STMT and insert outside the loop. */ gimple_seq stmts = NULL; - tree new_tree = build3 (BIT_FIELD_REF, TREE_TYPE (vectype), vec_lhs, bitsize, - bitstart); + tree bftype = TREE_TYPE (vectype); + if (VECTOR_BOOLEAN_TYPE_P (vectype)) + bftype = build_nonstandard_integer_type (tree_to_uhwi (bitsize), 1); + tree new_tree = build3 (BIT_FIELD_REF, bftype, vec_lhs, bitsize, bitstart); new_tree = force_gimple_operand (fold_convert (lhs_type, new_tree), &stmts, true, NULL_TREE); if (stmts) --- gcc/testsuite/gcc.c-torture/execute/pr78675.c.jj 2016-12-05 11:11:27.497407240 +0100 +++ gcc/testsuite/gcc.c-torture/execute/pr78675.c 2016-12-05 11:10:44.000000000 +0100 @@ -0,0 +1,38 @@ +/* PR tree-optimization/78675 */ + +long int a; + +__attribute__((noinline, noclone)) long int +foo (long int x) +{ + long int b; + while (a < 1) + { + b = a && x; + ++a; + } + return b; +} + +int +main () +{ + if (foo (0) != 0) + __builtin_abort (); + a = 0; + if (foo (1) != 0) + __builtin_abort (); + a = 0; + if (foo (25) != 0) + __builtin_abort (); + a = -64; + if (foo (0) != 0) + __builtin_abort (); + a = -64; + if (foo (1) != 0) + __builtin_abort (); + a = -64; + if (foo (25) != 0) + __builtin_abort (); + return 0; +} --- gcc/testsuite/gcc.target/i386/pr78675-1.c.jj 2016-12-05 11:11:27.497407240 +0100 +++ gcc/testsuite/gcc.target/i386/pr78675-1.c 2016-12-05 11:10:44.000000000 +0100 @@ -0,0 +1,5 @@ +/* PR tree-optimization/78675 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -mavx512f" } */ + +#include "../../gcc.c-torture/execute/pr78675.c" --- gcc/testsuite/gcc.target/i386/pr78675-2.c.jj 2016-12-05 11:13:48.131631261 +0100 +++ gcc/testsuite/gcc.target/i386/pr78675-2.c 2016-12-05 11:14:00.582474027 +0100 @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#include "avx512f-check.h" + +#define main do_main + +#include "../../gcc.c-torture/execute/pr78675.c" + +static void +avx512f_test (void) +{ + do_main (); +} Jakub