The vectorizer duplicates pointer-info to created pointer bases
but it has to avoid changing points-to info on existing SSA names
because there's now flow-sensitive info in there (pt->pt_null as
set from VRP).
2021-10-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/102798
* tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
Only copy points-to info to newly generated SSA names.
* gcc.dg/pr102798.c: New testcase.
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-tree-pta" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+__attribute__((__noipa__))
+void BUF_reverse (unsigned char *out, const unsigned char *in, size_t size)
+{
+ size_t i;
+ if (in)
+ {
+ out += size - 1;
+ for (i = 0; i < size; i++)
+ *out++ = *in++;
+ }
+ else
+ {
+ unsigned char *q;
+ char c;
+ q = out + size - 1;
+ for (i = 0; i < size ; i++)
+ {
+ *out++ = 1;
+ }
+ }
+}
+
+int
+main (void)
+{
+ unsigned char buf[40];
+ unsigned char buf1[40];
+ for (unsigned i = 0; i < sizeof (buf); i++)
+ buf[i] = i;
+ BUF_reverse (buf, 0, sizeof (buf));
+ for (unsigned i = 0; i < sizeof (buf); i++)
+ if (buf[i] != 1)
+ __builtin_abort ();
+
+ return 0;
+}
if (DR_PTR_INFO (dr)
&& TREE_CODE (addr_base) == SSA_NAME
- && !SSA_NAME_PTR_INFO (addr_base))
- vect_duplicate_ssa_name_ptr_info (addr_base, dr_info);
+ /* We should only duplicate pointer info to newly created SSA names. */
+ && SSA_NAME_VAR (addr_base) == dest)
+ {
+ gcc_assert (!SSA_NAME_PTR_INFO (addr_base));
+ vect_duplicate_ssa_name_ptr_info (addr_base, dr_info);
+ }
if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location, "created %T\n", addr_base);