The get_pointer_alignment function can indicate that it does not know what the alignment should be, and it always fills in worst-case values for that case. We should not use these worst-case values to "optimize" the interface of a function.
At minimum I think something like the following would be good. But I'm unsure why we would *ever* want to lower the alignment at a function interface. It seems to me that we'd simply want the caller to handle copying the data to an aligned location? What was the use case of this code in the first place? r~
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 3150bd6..d117389 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -2956,15 +2956,17 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt, unsigned int align; unsigned HOST_WIDE_INT misalign; - get_pointer_alignment_1 (base, &align, &misalign); - misalign += (tree_to_double_int (off) - .sext (TYPE_PRECISION (TREE_TYPE (off))).low - * BITS_PER_UNIT); - misalign = misalign & (align - 1); - if (misalign != 0) - align = (misalign & -misalign); - if (align < TYPE_ALIGN (type)) - type = build_aligned_type (type, align); + if (get_pointer_alignment_1 (base, &align, &misalign)) + { + misalign += (tree_to_double_int (off) + .sext (TYPE_PRECISION (TREE_TYPE (off))).low + * BITS_PER_UNIT); + misalign = misalign & (align - 1); + if (misalign != 0) + align = (misalign & -misalign); + if (align < TYPE_ALIGN (type)) + type = build_aligned_type (type, align); + } expr = fold_build2_loc (loc, MEM_REF, type, base, off); } else