aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-sccvn.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-10-05 14:35:15 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2011-10-05 14:35:15 +0000
commitc867aba0c04643ea47cec651cb270e6d09c17f28 (patch)
tree3088e902d6379ea1f7ad70c2358f94e554dcb80d /gcc/tree-ssa-sccvn.c
parent484db665a35edd7c5e4112331665da4dfe57affd (diff)
downloadgcc-c867aba0c04643ea47cec651cb270e6d09c17f28.zip
gcc-c867aba0c04643ea47cec651cb270e6d09c17f28.tar.gz
gcc-c867aba0c04643ea47cec651cb270e6d09c17f28.tar.bz2
re PR tree-optimization/38885 (missed FRE with BIT_FIELD_REF and vectors)
2011-10-05 Richard Guenther <rguenther@suse.de> PR tree-optimization/38885 * tree-ssa-sccvn.c (vn_reference_lookup_3): Handle partial reads from constants. * gcc.dg/tree-ssa/ssa-fre-33.c: New testcase. From-SVN: r179556
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r--gcc/tree-ssa-sccvn.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 4b5d388..3b1ad3d 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -1442,7 +1442,54 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_)
}
}
- /* 3) For aggregate copies translate the reference through them if
+ /* 3) Assignment from a constant. We can use folds native encode/interpret
+ routines to extract the assigned bits. */
+ else if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
+ && ref->size == maxsize
+ && maxsize % BITS_PER_UNIT == 0
+ && offset % BITS_PER_UNIT == 0
+ && is_gimple_reg_type (vr->type)
+ && gimple_assign_single_p (def_stmt)
+ && is_gimple_min_invariant (gimple_assign_rhs1 (def_stmt)))
+ {
+ tree base2;
+ HOST_WIDE_INT offset2, size2, maxsize2;
+ base2 = get_ref_base_and_extent (gimple_assign_lhs (def_stmt),
+ &offset2, &size2, &maxsize2);
+ if (maxsize2 != -1
+ && maxsize2 == size2
+ && size2 % BITS_PER_UNIT == 0
+ && offset2 % BITS_PER_UNIT == 0
+ && operand_equal_p (base, base2, 0)
+ && offset2 <= offset
+ && offset2 + size2 >= offset + maxsize)
+ {
+ /* We support up to 512-bit values (for V8DFmode). */
+ unsigned char buffer[64];
+ int len;
+
+ len = native_encode_expr (gimple_assign_rhs1 (def_stmt),
+ buffer, sizeof (buffer));
+ if (len > 0)
+ {
+ tree val = native_interpret_expr (vr->type,
+ buffer
+ + ((offset - offset2)
+ / BITS_PER_UNIT),
+ ref->size / BITS_PER_UNIT);
+ if (val)
+ {
+ unsigned int value_id = get_or_alloc_constant_value_id (val);
+ return vn_reference_insert_pieces
+ (vuse, vr->set, vr->type,
+ VEC_copy (vn_reference_op_s, heap, vr->operands),
+ val, value_id);
+ }
+ }
+ }
+ }
+
+ /* 4) For aggregate copies translate the reference through them if
the copy kills ref. */
else if (vn_walk_kind == VN_WALKREWRITE
&& gimple_assign_single_p (def_stmt)
@@ -1540,7 +1587,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_)
return NULL;
}
- /* 4) For memcpy copies translate the reference through them if
+ /* 5) For memcpy copies translate the reference through them if
the copy kills ref. */
else if (vn_walk_kind == VN_WALKREWRITE
&& is_gimple_reg_type (vr->type)