--- /dev/null
+/* { 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" } } */
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))
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] = {};
&& 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);
}