]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/118062 - bogus lowering of vector compares
authorRichard Biener <rguenther@suse.de>
Tue, 17 Dec 2024 10:23:02 +0000 (11:23 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 17 Dec 2024 18:08:10 +0000 (19:08 +0100)
The generic expand_vector_piecewise routine supports lowering of
a vector operation to vector operations of smaller size.  When
computing the extract position from the larger vector it uses the
element size in bits of the original result vector to determine
the number of elements in the smaller vector.  That is wrong when
lowering a compare as the vector element size of a bool vector
does not have to agree with that of the compare operand.  The
following simplifies this, fixing the error.

PR middle-end/118062
* tree-vect-generic.cc (expand_vector_piecewise): Properly
compute delta.

gcc/tree-vect-generic.cc

index 78f6e552cc7ba36b61a560b4ba4f759ec54019d6..4b9cf734bdd1bf96962f4762074d8d356f32c282 100644 (file)
@@ -292,7 +292,8 @@ expand_vector_piecewise (gimple_stmt_iterator *gsi, elem_op_func f,
   tree part_width = TYPE_SIZE (inner_type);
   tree index = bitsize_int (0);
   int nunits = nunits_for_known_piecewise_op (type);
-  int delta = tree_to_uhwi (part_width) / vector_element_bits (type);
+  int delta = (VECTOR_TYPE_P (inner_type)
+              ? nunits_for_known_piecewise_op (inner_type) : 1);
   int i;
   location_t loc = gimple_location (gsi_stmt (*gsi));