This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix middle-end/38747 (Wrong code due to VIEW_CONVERT_EXPR) and middle-end/38748 (Missed FRE because of VIEW_CONVERT_EXPR)


Hi,
  The problem here is that forward prop can cause an aliasing problem
that did not exist in the original source.  So currently we transform
*(*int)&a->float_field into VIEW_CONVERT_EXPR<int>(a->float_field).
This causes an aliasing issue if the aliasing sets of int and float
don't overlap.  So we want to disable this transformation if the inner
most reference is an INDIRECT_REF and the aliasing sets don't match or
the aliasing set for the access of the INDIRECT_REF will be 0.  Just
disabling it for all INDIRECT_REFs will disabling some optimizations
when the aliasing sets are the same and the VIEW_CONVERT_EXPR could be
changed into a NOP_EXPR (think unsigned int and signed int, I added a
testcase for that).

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Disable the VCE
conversion if the base address is an indirect reference and the
aliasing sets could cause issues.

* gcc.dg/tree-ssa/struct-aliasing-1.c: New test.
* gcc.dg/tree-ssa/struct-aliasing-2.c: New test.
* gcc.c-torture/execute/struct-aliasing-1.c: New test.

Attachment: fixpr38747.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]