aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-sccvn.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-03-12 14:18:35 +0100
committerRichard Biener <rguenther@suse.de>2020-03-12 14:19:36 +0100
commit1dc00a8ec9aeba86b74b16bff6f171824bb7b4a1 (patch)
treeeadb3fa8164c3ad87d25d9a15f97b463e138cef6 /gcc/tree-ssa-sccvn.c
parentfcc443b97e19d9c8a2d8ccdfa4cc20682165827e (diff)
downloadgcc-1dc00a8ec9aeba86b74b16bff6f171824bb7b4a1.zip
gcc-1dc00a8ec9aeba86b74b16bff6f171824bb7b4a1.tar.gz
gcc-1dc00a8ec9aeba86b74b16bff6f171824bb7b4a1.tar.bz2
tree-optimization/94103 avoid CSE of loads with padding
VN currently replaces a load of a 16 byte entity 128 bits of precision (TImode) with the result of a load of a 16 byte entity with 80 bits of mode precision (XFmode). That will go downhill since if the padding bits are not actually filled with memory contents those bits are missing. 2020-03-12 Richard Biener <rguenther@suse.de> PR tree-optimization/94103 * tree-ssa-sccvn.c (visit_reference_op_load): Avoid type punning when the mode precision is not sufficient. * gcc.target/i386/pr94103.c: New testcase.
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r--gcc/tree-ssa-sccvn.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index b7174cd..150ddad 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -4899,13 +4899,22 @@ visit_reference_op_load (tree lhs, tree op, gimple *stmt)
if (result
&& !useless_type_conversion_p (TREE_TYPE (result), TREE_TYPE (op)))
{
- /* We will be setting the value number of lhs to the value number
- of VIEW_CONVERT_EXPR <TREE_TYPE (result)> (result).
- So first simplify and lookup this expression to see if it
- is already available. */
- gimple_match_op res_op (gimple_match_cond::UNCOND,
- VIEW_CONVERT_EXPR, TREE_TYPE (op), result);
- result = vn_nary_build_or_lookup (&res_op);
+ /* Avoid the type punning in case the result mode has padding where
+ the op we lookup has not. */
+ if (maybe_lt (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (result))),
+ GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (op)))))
+ result = NULL_TREE;
+ else
+ {
+ /* We will be setting the value number of lhs to the value number
+ of VIEW_CONVERT_EXPR <TREE_TYPE (result)> (result).
+ So first simplify and lookup this expression to see if it
+ is already available. */
+ gimple_match_op res_op (gimple_match_cond::UNCOND,
+ VIEW_CONVERT_EXPR, TREE_TYPE (op), result);
+ result = vn_nary_build_or_lookup (&res_op);
+ }
+
/* When building the conversion fails avoid inserting the reference
again. */
if (!result)