Commit 5e135c82 authored by Andreas Fried's avatar Andreas Fried
Browse files

Fix read-after-write optimization.

Previously, if the load and store mode were equal, the optimization
aborted immediately. This is not necessary, we must only abort if the load
and store modes' arithmetic are not equal.

This causes a bug in type-based alias analysis to appear: When a CopyB is
lowered to Loads and Stores, the modes of these are always Iu instead of
the actual modes of the struct's members. The test-case "opt/fehler199.c"
will fail as a result.

Therefore, type-based alias analysis is switched off in cparser.
parent 25c3a1fb
......@@ -689,25 +689,26 @@ static int try_load_after_store(ir_node *load,
if (delta < 0 || delta+load_mode_len > store_mode_len)
return 0;
if (store_mode != load_mode &&
get_mode_arithmetic(store_mode) == irma_twos_complement &&
get_mode_arithmetic(load_mode) == irma_twos_complement) {
/* produce a shift to adjust offset delta */
unsigned const shift = be_get_backend_param()->byte_order_big_endian
? store_mode_len - load_mode_len - delta
: delta;
if (shift != 0) {
ir_graph *const irg = get_irn_irg(load);
ir_node *const cnst = new_r_Const_long(irg, mode_Iu, shift * 8);
store_value = new_r_Shr(get_nodes_block(load),
store_value, cnst, store_mode);
}
if (store_mode != load_mode) {
if (get_mode_arithmetic(store_mode) == irma_twos_complement &&
get_mode_arithmetic(load_mode) == irma_twos_complement) {
/* produce a shift to adjust offset delta */
unsigned const shift = be_get_backend_param()->byte_order_big_endian
? store_mode_len - load_mode_len - delta
: delta;
if (shift != 0) {
ir_graph *const irg = get_irn_irg(load);
ir_node *const cnst = new_r_Const_long(irg, mode_Iu, shift * 8);
store_value = new_r_Shr(get_nodes_block(load),
store_value, cnst, store_mode);
}
store_value = new_r_Conv(get_nodes_block(load), store_value, load_mode);
} else {
/* we would need some kind of bitcast node here */
return 0;
store_value = new_r_Conv(get_nodes_block(load), store_value, load_mode);
} else {
/* we would need some kind of bitcast node here */
return 0;
}
}
DBG_OPT_RAW(load, store_value);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment