The following patch fixes PR71816. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard. 2016-07-11 Richard Biener <rguent...@suse.de> PR tree-optimization/71816 * tree-ssa-pre.c (compute_avail): Adjust alignment of ref rather than replacing all of its operands. * gcc.dg/torture/pr71816.c: New testcase. Index: gcc/tree-ssa-pre.c =================================================================== *** gcc/tree-ssa-pre.c (revision 238206) --- gcc/tree-ssa-pre.c (working copy) *************** compute_avail (void) *** 3791,3803 **** || ref1->opcode == MEM_REF) && (TYPE_ALIGN (ref1->type) > TYPE_ALIGN (ref2->type))) ! { ! ref->operands.release (); ! ref->operands = operands; ! ref1 = ref2; ! } ! else ! operands.release (); /* TBAA behavior is an obvious part so make sure that the hashtable one covers this as well by adjusting the ref alias set and its base. */ --- 3791,3799 ---- || ref1->opcode == MEM_REF) && (TYPE_ALIGN (ref1->type) > TYPE_ALIGN (ref2->type))) ! ref1->type ! = build_aligned_type (ref1->type, ! TYPE_ALIGN (ref2->type)); /* TBAA behavior is an obvious part so make sure that the hashtable one covers this as well by adjusting the ref alias set and its base. */ *************** compute_avail (void) *** 3824,3829 **** --- 3820,3826 ---- ref1->op2 = fold_convert (ptr_type_node, ref1->op2); } + operands.release (); result = pre_expr_pool.allocate (); result->kind = REFERENCE; Index: gcc/testsuite/gcc.dg/torture/pr71816.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr71816.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr71816.c (working copy) *************** *** 0 **** --- 1,21 ---- + /* { dg-do compile } */ + + void *ext2fs_resize_mem_p; + struct ext2_icount_el { + int ino; + } * insert_icount_el_icount_1; + int insert_icount_el_icount, insert_icount_el_new_size; + void *memcpy(); + void *realloc(); + int ext2fs_resize_mem(void *p1) { + int size = 0; + memcpy(&ext2fs_resize_mem_p, p1, sizeof(ext2fs_resize_mem_p)); + realloc(&ext2fs_resize_mem_p, size); + return 0; + } + struct ext2_icount_el *insert_icount_el() { + if (insert_icount_el_icount) + insert_icount_el_new_size = insert_icount_el_icount_1[0].ino; + ext2fs_resize_mem(&insert_icount_el_icount_1); + return 0; + }