This patch cures a problem with ICF of read-only variables at the
intersection of -fsection-anchors, -ftree-loop-vectorize, and targets
with alignment restrictions.
What happens with the testcase is:
- "c" is referenced in a constructor, thus make_decl_rtl for "c",
- make_decl_rtl puts "c" in an anchor block (-fsection-anchors),
- anchor block contents can't move, so "c" alignment can't change by
ipa_increase_alignment (-ftree-loop-vectorize),
- however "a" alignment can be increased,
- ICF aliases "a" to "c".
So we have a decl for "a" saying it is aligned to 128 bits, using mem
for "c" which is only 16 bit aligned.
PR ipa/69990
gcc/
* ipa-icf.c (sem_variable::merge): Do not merge an alias with
larger alignment.
gcc/testsuite/
gcc.dg/pr69990.c: New.
From-SVN: r233906
+2016-03-02 Alan Modra <amodra@gmail.com>
+
+ PR ipa/69990
+ * ipa-icf.c (sem_variable::merge): Do not merge an alias with
+ larger alignment.
+
2016-03-02 Jakub Jelinek <jakub@redhat.com>
PR target/70028
"adress of original and alias may be compared.\n\n");
return false;
}
+
+ if (DECL_ALIGN (original->decl) < DECL_ALIGN (alias->decl))
+ {
+ if (dump_file)
+ fprintf (dump_file, "Not unifying; "
+ "original and alias have incompatible alignments\n\n");
+
+ return false;
+ }
+
if (DECL_COMDAT_GROUP (original->decl) != DECL_COMDAT_GROUP (alias->decl))
{
if (dump_file)
+2016-03-02 Alan Modra <amodra@gmail.com>
+
+ * gcc.dg/pr69990.c: New.
+
2016-03-02 Jakub Jelinek <jakub@redhat.com>
PR c/68062
--- /dev/null
+/* { dg-do run } */
+/* { dg-require-effective-target section_anchors } */
+/* { dg-options "-O2 -fsection-anchors -ftree-loop-vectorize" } */
+
+#pragma pack(1)
+struct S0 {
+ volatile int f0:12;
+} static a[] = {{15}}, c[] = {{15}};
+
+struct S0 b[] = {{7}};
+
+int __attribute__ ((noinline, noclone))
+ok (int a, int b, int c)
+{
+ return a == 15 && b == 7 && c == 15 ? 0 : 1;
+}
+
+int
+main (void)
+{
+ struct S0 *f[] = { c, b };
+
+ return ok (a[0].f0, b[0].f0, f[0]->f0);
+}