diff --git a/gcc/testsuite/gcc.dg/torture/pr113630.c b/gcc/testsuite/gcc.dg/torture/pr113630.c new file mode 100644 index 00000000000..72ebdefae27 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr113630.c @@ -0,0 +1,4 @@ +/* { dg-do run { target { { *-*-linux* *-*-gnu* *-*-uclinux* } && mmap } } } */ +/* { dg-additional-options "-fno-strict-aliasing" } */ + +#include "pr110799.c" diff --git a/gcc/tree-ssa-pre.cc b/gcc/tree-ssa-pre.cc index e72592de5e5..d29214d04f8 100644 --- a/gcc/tree-ssa-pre.cc +++ b/gcc/tree-ssa-pre.cc @@ -4281,6 +4281,20 @@ compute_avail (function *fun) = wide_int_to_tree (ptr_type_node, wi::to_wide (ref1->op2)); } + /* We also need to make sure that the access path + ends in an access of the same size as otherwise + we might assume an access may not trap while in + fact it might. That's independent of whether + TBAA is in effect. */ + if (TYPE_SIZE (ref1->type) != TYPE_SIZE (ref2->type) + && (! TYPE_SIZE (ref1->type) + || ! TYPE_SIZE (ref2->type) + || ! operand_equal_p (TYPE_SIZE (ref1->type), + TYPE_SIZE (ref2->type)))) + { + operands.release (); + continue; + } operands.release (); result = get_or_alloc_expr_for_reference