https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98674
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2021-01-14 CC| |rguenth at gcc dot gnu.org, | |rsandifo at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- (compute_affine_dependence stmt_a: load_dst_23 = MEM[(short int *)p_21]; stmt_b: *p_21 = _8; ) -> dependence analysis failed x.c:1:6: missed: versioning for alias required: can't determine dependence between MEM[(short int *)p_21] and *p_21 consider run-time aliasing test between MEM[(short int *)p_21] and *p_21 so the issue is that dependence analysis fails. A dependence distance of zero would be OK. Above we see two different base objects, one accesses the ref as 'short int' and one as 'unsigned short int' (but with short int alias type). We're doing bool same_base_p = (full_seq.start_a + full_seq.length == num_dimensions_a && full_seq.start_b + full_seq.length == num_dimensions_b && DR_UNCONSTRAINED_BASE (a) == DR_UNCONSTRAINED_BASE (b) && operand_equal_p (base_a, base_b, OEP_ADDRESS_OF) && types_compatible_p (TREE_TYPE (base_a), TREE_TYPE (base_b)) && (!loop_nest.exists () || (object_address_invariant_in_loop_p (loop_nest[0], base_a)))); and "fail" the types_compatible_p test which for non-aggregate types is probably too strict and could be relaxed to at least consider signed/unsigned type variants as the same. Maybe for non-aggregate types just compare the mode. Richard, you refactored this code last? For example diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 394470af757..1853f4b4a07 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -3272,8 +3272,11 @@ initialize_data_dependence_relation (struct data_reference *a, && full_seq.start_b + full_seq.length == num_dimensions_b && DR_UNCONSTRAINED_BASE (a) == DR_UNCONSTRAINED_BASE (b) && operand_equal_p (base_a, base_b, OEP_ADDRESS_OF) - && types_compatible_p (TREE_TYPE (base_a), - TREE_TYPE (base_b)) + && ((!AGGREGATE_TYPE_P (TREE_TYPE (base_a)) + && !AGGREGATE_TYPE_P (TREE_TYPE (base_b)) + && TYPE_MODE (TREE_TYPE (base_a)) == TYPE_MODE (TREE_TYPE (base_b))) + || types_compatible_p (TREE_TYPE (base_a), + TREE_TYPE (base_b))) && (!loop_nest.exists () || (object_address_invariant_in_loop_p (loop_nest[0], base_a)))); makes this vectorized but in the end the same_base_p check is supposed to verify whether access functions generated are comparable.