aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-08-21 11:45:34 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2019-08-21 11:45:34 +0000
commitd6dea10acfd9d775f260a2e7c319bb1ee64c0af0 (patch)
tree4643749b529ef1dd3d1f4012fc5e77f628c9ea32 /gcc/tree-ssa-ccp.c
parent8bb2ee59398df615bf4b7c8fa6db2944485e4204 (diff)
downloadgcc-d6dea10acfd9d775f260a2e7c319bb1ee64c0af0.zip
gcc-d6dea10acfd9d775f260a2e7c319bb1ee64c0af0.tar.gz
gcc-d6dea10acfd9d775f260a2e7c319bb1ee64c0af0.tar.bz2
re PR tree-optimization/91482 (__builtin_assume_aligned should not break write combining)
2019-08-21 Richard Biener <rguenther@suse.de> PR tree-optimization/91482 * tree-ssa-ccp.c (ccp_folder::fold_stmt): Remove useless BUILT_IN_ASSUME_ALIGNED calls. * gcc.dg/tree-ssa/pr91482.c: New testcase. From-SVN: r274796
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 458b218..5af3810 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2315,6 +2315,32 @@ ccp_folder::fold_stmt (gimple_stmt_iterator *gsi)
}
}
+ /* If there's no extra info from an assume_aligned call,
+ drop it so it doesn't act as otherwise useless dataflow
+ barrier. */
+ if (gimple_call_builtin_p (stmt, BUILT_IN_ASSUME_ALIGNED))
+ {
+ tree ptr = gimple_call_arg (stmt, 0);
+ ccp_prop_value_t ptrval = get_value_for_expr (ptr, true);
+ if (ptrval.lattice_val == CONSTANT
+ && TREE_CODE (ptrval.value) == INTEGER_CST
+ && ptrval.mask != 0)
+ {
+ ccp_prop_value_t val
+ = bit_value_assume_aligned (stmt, NULL_TREE, ptrval, false);
+ unsigned int ptralign = least_bit_hwi (ptrval.mask.to_uhwi ());
+ unsigned int align = least_bit_hwi (val.mask.to_uhwi ());
+ if (ptralign == align
+ && ((TREE_INT_CST_LOW (ptrval.value) & (align - 1))
+ == (TREE_INT_CST_LOW (val.value) & (align - 1))))
+ {
+ bool res = update_call_from_tree (gsi, ptr);
+ gcc_assert (res);
+ return true;
+ }
+ }
+ }
+
/* Propagate into the call arguments. Compared to replace_uses_in
this can use the argument slot types for type verification
instead of the current argument type. We also can safely