--- /dev/null
+/* { dg-do run } */
+/* { dg-require-effective-target riscv_v_ok } */
+/* { dg-options "-O3 -march=rv64gcv -mabi=lp64d" } */
+
+long long a;
+int b[22];
+_Bool c[22];
+
+int main() {
+ for (long f=0; f<10; ++f)
+ b[f] = c[f] = 1;
+ for (int f=0; f<5; f++)
+ for( int g=0; g<5; g++)
+ c[g*2] &= (_Bool)b[2*f];
+ for (long f=0; f<2; ++f)
+ a ^= c[f];
+ if (a != 0)
+ __builtin_abort ();
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=rv64gcv -mabi=lp64d -fdump-tree-optimized" } */
+
+long long a;
+int b[22];
+_Bool c[22];
+
+int main() {
+ for (long f=0; f<10; ++f)
+ b[f] = c[f] = 1;
+ for (int f=0; f<5; f++)
+ for( int g=0; g<5; g++)
+ c[g*2] &= (_Bool)b[2*f];
+ for (long f=0; f<2; ++f)
+ a ^= c[f];
+ if (a != 0)
+ __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump-not "BIT_FIELD_REF <\\{ -1, -1, -1, -1 \\}," "optimized" } } */
if (reduce_with_shift && (!slp_reduc || group_size == 1))
{
- tree bitsize = TYPE_SIZE (TREE_TYPE (vectype1));
- int element_bitsize = tree_to_uhwi (bitsize);
+ int element_bitsize = vector_element_bits (vectype1);
/* Enforced by vectorizable_reduction, which disallows SLP reductions
for variable-length vectors and also requires direct target support
for loop reductions. */
- int vec_size_in_bits = tree_to_uhwi (TYPE_SIZE (vectype1));
- int nelements = vec_size_in_bits / element_bitsize;
+ int nelements = TYPE_VECTOR_SUBPARTS (vectype1).to_constant ();
vec_perm_builder sel;
vec_perm_indices indices;
"extract scalar result\n");
new_temp = gimple_build (&stmts, BIT_FIELD_REF, TREE_TYPE (vectype1),
- new_temp, bitsize, bitsize_zero_node);
+ new_temp, bitsize_int (element_bitsize),
+ bitsize_zero_node);
new_temp = gimple_convert (&stmts, scalar_type, new_temp);
gsi_insert_seq_before (&exit_gsi, stmts, GSI_SAME_STMT);
scalar_results.safe_push (new_temp);
"Reduce using scalar code.\n");
tree compute_type = TREE_TYPE (vectype1);
- unsigned vec_size_in_bits = tree_to_uhwi (TYPE_SIZE (vectype1));
unsigned element_bitsize = vector_element_bits (vectype1);
+ unsigned vec_size_in_bits = element_bitsize
+ * TYPE_VECTOR_SUBPARTS (vectype1).to_constant ();
tree bitsize = bitsize_int (element_bitsize);
gimple_seq stmts = NULL;
FOR_EACH_VEC_ELT (reduc_inputs, i, vec_temp)