diff options
author | Richard Biener <rguenther@suse.de> | 2017-10-24 13:51:45 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-10-24 13:51:45 +0000 |
commit | da76b2532f85d0e928862303b1fc92fa2a5a6138 (patch) | |
tree | f72cf1f121e8ed72233293ec677e54a9f8894541 /gcc/tree-ssa-phiopt.c | |
parent | eab01c18fdf287aaac60224ddbecae6574631b7b (diff) | |
download | gcc-da76b2532f85d0e928862303b1fc92fa2a5a6138.zip gcc-da76b2532f85d0e928862303b1fc92fa2a5a6138.tar.gz gcc-da76b2532f85d0e928862303b1fc92fa2a5a6138.tar.bz2 |
re PR tree-optimization/82697 (Wrong optimization with aliasing and "if")
2017-10-24 Richard Biener <rguenther@suse.de>
PR tree-optimization/82697
* tree-ssa-phiopt.c (cond_store_replacement): Use alias-set
zero for conditional load and unconditional store.
* gcc.dg/torture/pr82697.c: New testcase.
From-SVN: r254047
Diffstat (limited to 'gcc/tree-ssa-phiopt.c')
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index d0570c3..6e0e186 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -1912,9 +1912,24 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, gsi_remove (&gsi, true); release_defs (assign); + /* Make both store and load use alias-set zero as we have to + deal with the case of the store being a conditional change + of the dynamic type. */ + lhs = unshare_expr (lhs); + tree *basep = &lhs; + while (handled_component_p (*basep)) + basep = &TREE_OPERAND (*basep, 0); + if (TREE_CODE (*basep) == MEM_REF + || TREE_CODE (*basep) == TARGET_MEM_REF) + TREE_OPERAND (*basep, 1) + = fold_convert (ptr_type_node, TREE_OPERAND (*basep, 1)); + else + *basep = build2 (MEM_REF, TREE_TYPE (*basep), + build_fold_addr_expr (*basep), + build_zero_cst (ptr_type_node)); + /* 2) Insert a load from the memory of the store to the temporary on the edge which did not contain the store. */ - lhs = unshare_expr (lhs); name = make_temp_ssa_name (TREE_TYPE (lhs), NULL, "cstore"); new_stmt = gimple_build_assign (name, lhs); gimple_set_location (new_stmt, locus); |