From: Richard Biener Date: Wed, 23 May 2018 07:08:43 +0000 (+0000) Subject: tree-ssa-sccvn.c (vn_reference_lookup_3): Handle arbitrary memset constants via nativ... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b72feab889cd7925fab59771269638fcc88bc195;p=gcc.git tree-ssa-sccvn.c (vn_reference_lookup_3): Handle arbitrary memset constants via native_interpret_expr. 2018-05-23 Richard Biener * tree-ssa-sccvn.c (vn_reference_lookup_3): Handle arbitrary memset constants via native_interpret_expr. * gcc.dg/tree-ssa/ssa-fre-65.c: New testcase. From-SVN: r260565 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 79a5e374d5a..fbb0120c497 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-05-23 Richard Biener + + * tree-ssa-sccvn.c (vn_reference_lookup_3): Handle arbitrary + memset constants via native_interpret_expr. + 2018-05-22 H.J. Lu PR target/85345 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 21e58d3e3a7..6bd7a1546cd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-05-23 Richard Biener + + * gcc.dg/tree-ssa/ssa-fre-65.c: New testcase. + 2018-05-22 Janus Weil PR fortran/85841 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-65.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-65.c new file mode 100644 index 00000000000..87ba6662041 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-65.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre1-details -fdump-tree-dse1-details" } */ + +typedef unsigned char v16qi __attribute__((vector_size(16))); +typedef unsigned short v8hi __attribute__((vector_size(16))); +typedef unsigned int v4si __attribute__((vector_size(16))); +void foo(char *dest) +{ + unsigned char x[256] __attribute__((aligned(16))); + __builtin_memset (x, 23, 256); + v16qi resqi = *(v16qi *)&x[16]; + v8hi reshi = *(v8hi *)&x[16]; + v4si ressi = *(v4si *)&x[16]; + *(v16qi *)dest = resqi; + *(v8hi *)(dest + 16) = reshi; + *(v4si *)(dest + 32) = ressi; +} + +/* { dg-final { scan-tree-dump-times "Replaced MEM" 3 "fre1" } } */ +/* { dg-final { scan-tree-dump-times "Deleted dead call" 1 "dse1" } } */ diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 884cce12bb3..96e80c7b5a3 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -1959,9 +1959,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, if (is_gimple_reg_type (vr->type) && gimple_call_builtin_p (def_stmt, BUILT_IN_MEMSET) && (integer_zerop (gimple_call_arg (def_stmt, 1)) - || (INTEGRAL_TYPE_P (vr->type) + || ((TREE_CODE (gimple_call_arg (def_stmt, 1)) == INTEGER_CST + || (INTEGRAL_TYPE_P (vr->type) && known_eq (ref->size, 8))) && CHAR_BIT == 8 && BITS_PER_UNIT == 8 - && known_eq (ref->size, 8) && known_eq (ref->size, maxsize) && offset.is_constant (&offseti) && offseti % BITS_PER_UNIT == 0)) @@ -2030,7 +2030,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, tree val; if (integer_zerop (gimple_call_arg (def_stmt, 1))) val = build_zero_cst (vr->type); - else + else if (INTEGRAL_TYPE_P (vr->type) + && known_eq (ref->size, 8)) { code_helper rcode = NOP_EXPR; tree ops[3] = {}; @@ -2041,6 +2042,16 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (val))) return (void *)-1; } + else + { + unsigned len = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (vr->type)); + unsigned char *buf = XALLOCAVEC (unsigned char, len); + memset (buf, TREE_INT_CST_LOW (gimple_call_arg (def_stmt, 1)), + len); + val = native_interpret_expr (vr->type, buf, len); + if (!val) + return (void *)-1; + } return vn_reference_lookup_or_insert_for_pieces (vuse, vr->set, vr->type, vr->operands, val); }