From patchwork Tue Nov 20 17:24:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [RFC] PR 55415 : Pessimistic misalignment from eipa_sra pass X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 200487 Message-Id: <50ABBCC4.5070405@redhat.com> To: Martin Jambor Cc: GCC Patches Date: Tue, 20 Nov 2012 09:24:20 -0800 From: Richard Henderson List-Id: 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