Bug 80222 - may_alias folded away
Summary: may_alias folded away
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 7.0.1
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2017-03-27 13:18 UTC by Richard Biener
Modified: 2017-05-15 07:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 5.4.1, 6.3.1, 7.0.1
Known to fail: 5.4.0, 6.3.0
Last reconfirmed: 2017-03-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2017-03-27 13:18:59 UTC
struct C { int i; }__attribute__((may_alias)) ;

C a, b;

void foo()
{
  a = static_cast <C&> (b);
}

is folded away via gimplification / gimple_fold_indirect_ref.
Comment 1 Richard Biener 2017-03-27 13:19:11 UTC
Mine.
Comment 2 Richard Biener 2017-03-28 10:10:12 UTC
Fixed on trunk sofar.
Comment 3 Richard Biener 2017-03-28 10:10:32 UTC
Author: rguenth
Date: Tue Mar 28 10:10:01 2017
New Revision: 246527

URL: https://gcc.gnu.org/viewcvs?rev=246527&root=gcc&view=rev
Log:
2017-03-28  Richard Biener  <rguenther@suse.de>

	PR middle-end/80222
	* gimple-fold.c (gimple_fold_indirect_ref): Do not touch
	TYPE_REF_CAN_ALIAS_ALL references.
	* fold-const.c (fold_indirect_ref_1): Likewise.

	* g++.dg/pr80222.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/pr80222.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/gimple-fold.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Richard Biener 2017-05-09 12:27:56 UTC
Author: rguenth
Date: Tue May  9 12:27:24 2017
New Revision: 247790

URL: https://gcc.gnu.org/viewcvs?rev=247790&root=gcc&view=rev
Log:
2017-05-09  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2017-03-28  Richard Biener  <rguenther@suse.de>

	PR middle-end/80222
	* gimple-fold.c (gimple_fold_indirect_ref): Do not touch
	TYPE_REF_CAN_ALIAS_ALL references.
	* fold-const.c (fold_indirect_ref_1): Likewise.

	* g++.dg/pr80222.C: New testcase.

	2017-04-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/80262
	* tree-sra.c (build_ref_for_offset): Preserve address-space
	information.
	* tree-ssa-sccvn.c (vn_reference_maybe_forwprop_address):
	Drop useless address-space information on MEM_REF offsets.

	* gcc.target/i386/pr80262.c: New testcase.

	2017-04-03  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/80275
	* fold-const.c (split_address_to_core_and_offset): Handle
	POINTER_PLUS_EXPR.

	* g++.dg/opt/pr80275.C: New testcase.

	2017-04-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/80334
	* tree-ssa-loop-ivopts.c (rewrite_use_address): Properly
	preserve alignment of accesses.

	* g++.dg/torture/pr80334.C: New testcase.

	2017-04-10  Richard Biener  <rguenther@suse.de>

	PR middle-end/80362
	* fold-const.c (fold_binary_loc): Look at unstripped ops when
	looking for NEGATE_EXPR in -A / -B to A / B folding.

	* gcc.dg/torture/pr80362.c: New testcase.

	2017-04-25  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/80492
	* alias.c (compare_base_decls): Handle registers with asm
	specification conservatively.

	* gcc.dg/pr80492.c: New testcase.

	2017-04-27  Richard Biener  <rguenther@suse.de>

	PR middle-end/80539
	* tree-chrec.c (chrec_fold_plus_poly_poly): Deal with not
	being in loop-closed SSA form conservatively.
	(chrec_fold_multiply_poly_poly): Likewise.

	* gcc.dg/torture/pr80539.c: New testcase.

Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/opt/pr80275.C
    branches/gcc-6-branch/gcc/testsuite/g++.dg/pr80222.C
    branches/gcc-6-branch/gcc/testsuite/g++.dg/torture/pr80334.C
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/pr80492.c
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/torture/pr80362.c
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/torture/pr80539.c
    branches/gcc-6-branch/gcc/testsuite/gcc.target/i386/pr80262.c
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/alias.c
    branches/gcc-6-branch/gcc/fold-const.c
    branches/gcc-6-branch/gcc/gimple-fold.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
    branches/gcc-6-branch/gcc/tree-chrec.c
    branches/gcc-6-branch/gcc/tree-sra.c
    branches/gcc-6-branch/gcc/tree-ssa-loop-ivopts.c
    branches/gcc-6-branch/gcc/tree-ssa-sccvn.c
Comment 5 Richard Biener 2017-05-10 07:54:17 UTC
Author: rguenth
Date: Wed May 10 07:53:45 2017
New Revision: 247827

URL: https://gcc.gnu.org/viewcvs?rev=247827&root=gcc&view=rev
Log:
2017-05-10  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2017-03-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/80122
	* tree-inline.c (copy_bb): Do not expans va-arg packs or
	va_arg_pack_len when the inlined call stmt requires pack
	expansion itself.
	* tree-inline.h (struct copy_body_data): Make call_stmt a gcall *.

	* gcc.dg/torture/pr80122.c: New testcase.

	2017-03-28  Richard Biener  <rguenther@suse.de>

	PR middle-end/80222
	* gimple-fold.c (gimple_fold_indirect_ref): Do not touch
	TYPE_REF_CAN_ALIAS_ALL references.
	* fold-const.c (fold_indirect_ref_1): Likewise.

	* g++.dg/pr80222.C: New testcase.

	2017-04-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/80334
	* tree-ssa-loop-ivopts.c (rewrite_use_address): Properly
	preserve alignment of accesses.

	* g++.dg/torture/pr80334.C: New testcase.

	2017-04-27  Richard Biener  <rguenther@suse.de>

	PR middle-end/80539
	* tree-chrec.c (chrec_fold_plus_poly_poly): Deal with not
	being in loop-closed SSA form conservatively.
	(chrec_fold_multiply_poly_poly): Likewise.

	* gcc.dg/torture/pr80539.c: New testcase.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/pr80222.C
    branches/gcc-5-branch/gcc/testsuite/g++.dg/torture/pr80334.C
    branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr80122.c
    branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr80539.c
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/fold-const.c
    branches/gcc-5-branch/gcc/gimple-fold.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
    branches/gcc-5-branch/gcc/tree-chrec.c
    branches/gcc-5-branch/gcc/tree-inline.c
    branches/gcc-5-branch/gcc/tree-inline.h
    branches/gcc-5-branch/gcc/tree-ssa-loop-ivopts.c
Comment 6 Richard Biener 2017-05-10 07:54:55 UTC
Fixed.
Comment 7 Eric Botcazou 2017-05-13 09:41:52 UTC
Backporting onto the 6 branch introduced regressions:
  https://gcc.gnu.org/ml/gcc-patches/2017-05/msg01087.html
Comment 8 Richard Biener 2017-05-15 07:54:09 UTC
Author: rguenth
Date: Mon May 15 07:53:37 2017
New Revision: 248047

URL: https://gcc.gnu.org/viewcvs?rev=248047&root=gcc&view=rev
Log:
2017-05-15  Richard Biener  <rguenther@suse.de>

        Revert backport of
	PR middle-end/80222
	* gimple-fold.c (gimple_fold_indirect_ref): Do not touch
	TYPE_REF_CAN_ALIAS_ALL references.
	* fold-const.c (fold_indirect_ref_1): Likewise.

	* g++.dg/pr80222.C: New testcase.

Removed:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/pr80222.C
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/fold-const.c
    branches/gcc-6-branch/gcc/gimple-fold.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 9 Richard Biener 2017-05-15 07:56:32 UTC
Author: rguenth
Date: Mon May 15 07:56:00 2017
New Revision: 248048

URL: https://gcc.gnu.org/viewcvs?rev=248048&root=gcc&view=rev
Log:
2017-05-15  Richard Biener  <rguenther@suse.de>

        Revert backport of
	PR middle-end/80222
	* gimple-fold.c (gimple_fold_indirect_ref): Do not touch
	TYPE_REF_CAN_ALIAS_ALL references.
	* fold-const.c (fold_indirect_ref_1): Likewise.

	* g++.dg/pr80222.C: New testcase.

Removed:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/pr80222.C
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/fold-const.c
    branches/gcc-5-branch/gcc/gimple-fold.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 10 Richard Biener 2017-05-15 07:56:48 UTC
Fixed for GCC 7 instead.