--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2 -ftree-tail-merge" } */
+
+static inline void set_longish(int is_long_long, void *p, long x)
+{
+ if (is_long_long)
+ *(long long*)p = x;
+ else
+ *(long*)p = x;
+}
+static long test(long long *p, int index, int mode)
+{
+ *p = 1;
+ set_longish(mode, p+index, 2);
+ return *p;
+}
+long (*volatile vtest)(long long*, int, int) = test;
+int main(void)
+{
+ long long x;
+ long result = vtest(&x, 0, 1);
+ if (result != 2 || x != 2)
+ __builtin_abort ();
+ return 0;
+}
if (!resultsame)
{
- /* Only perform the following when being called from PRE
- which embeds tail merging. */
- if (default_vn_walk_kind == VN_WALK)
- {
- assign = build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, op);
- vn_reference_lookup (assign, vuse, VN_NOWALK, &vnresult, false);
- if (vnresult)
- {
- VN_INFO (vdef)->visited = true;
- return set_ssa_val_to (vdef, vnresult->result_vdef);
- }
- }
-
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "No store match\n");
if (default_vn_walk_kind == VN_WALK)
{
assign = build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, op);
- vn_reference_insert (assign, lhs, vuse, vdef);
+ vn_reference_lookup (assign, vuse, VN_NOWALK, &vnresult, false);
+ if (!vnresult)
+ vn_reference_insert (assign, lhs, vuse, vdef);
}
}
else