PR 49742: call lhs being ignored
Richard Sandiford
richard.sandiford@linaro.org
Tue Jul 19 12:26:00 GMT 2011
In 49742, we have:
vect_array.21 = LOAD_LANES (MEM[(int[512] *)vect_pin.17_56]);
vect_var_.22_58 = vect_array.21[0];
predcom doesn't think that there are any dependencies between
the two statements, so hoists the second one as an invariant.
This in turn is because get_references_in_stmt ignores the lhs
of calls.
Tested on x86_64-linux-gnu and arm-linux-gnueabi. OK to install?
Richard
gcc/
PR tree-optimization/49742
* tree-data-ref.c (get_references_in_stmt): Treat the lhs of a call
as a potential write.
Index: gcc/tree-data-ref.c
===================================================================
--- gcc/tree-data-ref.c 2011-07-19 10:53:10.000000000 +0100
+++ gcc/tree-data-ref.c 2011-07-19 13:08:12.000000000 +0100
@@ -4158,33 +4158,37 @@ get_references_in_stmt (gimple stmt, VEC
ref->pos = op1;
ref->is_read = true;
}
-
- if (DECL_P (*op0)
- || (REFERENCE_CLASS_P (*op0) && get_base_address (*op0)))
- {
- ref = VEC_safe_push (data_ref_loc, heap, *references, NULL);
- ref->pos = op0;
- ref->is_read = false;
- }
}
else if (stmt_code == GIMPLE_CALL)
{
- unsigned i, n = gimple_call_num_args (stmt);
+ unsigned i, n;
+ op0 = gimple_call_lhs_ptr (stmt);
+ n = gimple_call_num_args (stmt);
for (i = 0; i < n; i++)
{
- op0 = gimple_call_arg_ptr (stmt, i);
+ op1 = gimple_call_arg_ptr (stmt, i);
- if (DECL_P (*op0)
- || (REFERENCE_CLASS_P (*op0) && get_base_address (*op0)))
+ if (DECL_P (*op1)
+ || (REFERENCE_CLASS_P (*op1) && get_base_address (*op1)))
{
ref = VEC_safe_push (data_ref_loc, heap, *references, NULL);
- ref->pos = op0;
+ ref->pos = op1;
ref->is_read = true;
}
}
}
+ else
+ return clobbers_memory;
+ if (*op0
+ && (DECL_P (*op0)
+ || (REFERENCE_CLASS_P (*op0) && get_base_address (*op0))))
+ {
+ ref = VEC_safe_push (data_ref_loc, heap, *references, NULL);
+ ref->pos = op0;
+ ref->is_read = false;
+ }
return clobbers_memory;
}
More information about the Gcc-patches
mailing list