Commit 37482a19 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ldstopt: Preserve debug info in the load-after-load/store transformation.

parent b35193fc
......@@ -399,17 +399,18 @@ static bool is_contained_in(
static ir_node *transform_previous_value(ir_mode *const load_mode,
const long load_offset, ir_mode *const prev_mode,
const long prev_offset, ir_node *const prev_value,
ir_node *const block)
ir_node *const block, ir_node *const load)
{
/* simple case: previous value has the same mode */
if (load_mode == prev_mode)
return prev_value;
/* two complement values can be transformed with bitops */
long load_mode_len = get_mode_size_bytes(load_mode);
long prev_mode_len = get_mode_size_bytes(prev_mode);
ir_mode_arithmetic prev_arithmetic = get_mode_arithmetic(prev_mode);
ir_mode_arithmetic load_arithmetic = get_mode_arithmetic(load_mode);
dbg_info *const dbgi = get_irn_dbg_info(load);
long const load_mode_len = get_mode_size_bytes(load_mode);
long const prev_mode_len = get_mode_size_bytes(prev_mode);
ir_mode_arithmetic const prev_arithmetic = get_mode_arithmetic(prev_mode);
ir_mode_arithmetic const load_arithmetic = get_mode_arithmetic(load_mode);
if (prev_arithmetic == irma_twos_complement &&
load_arithmetic == irma_twos_complement) {
/* produce a shift to adjust offset delta */
......@@ -425,13 +426,13 @@ static ir_node *transform_previous_value(ir_mode *const load_mode,
}
ir_graph *const irg = get_irn_irg(block);
ir_node *const cnst = new_r_Const_long(irg, mode_Iu, shift * 8);
new_value = new_r_Shr(block, new_value, cnst);
new_value = new_rd_Shr(dbgi, block, new_value, cnst);
}
return new_r_Conv(block, new_value, load_mode);
return new_rd_Conv(dbgi, block, new_value, load_mode);
} else {
assert(prev_arithmetic != load_arithmetic && load_mode_len == prev_mode_len);
return new_r_Bitcast(block, prev_value, load_mode);
return new_rd_Bitcast(dbgi, block, prev_value, load_mode);
}
}
......@@ -493,7 +494,7 @@ static changes_t try_load_after_store(track_load_env_t *env, ir_node *store)
ir_node *const block = get_nodes_block(load);
ir_node *const new_value
= transform_previous_value(load_mode, base_offset->offset, store_mode,
prev_base_offset.offset, store_value, block);
prev_base_offset.offset, store_value, block, load);
DBG_OPT_RAW(load, new_value);
return replace_load(load, new_value);
}
......@@ -526,7 +527,7 @@ static changes_t try_load_after_load(track_load_env_t *env, ir_node *prev_load)
ir_node *const block = get_nodes_block(load);
ir_node *const new_value
= transform_previous_value(load_mode, base_offset->offset, prev_mode,
prev_base_offset.offset, prev_value, block);
prev_base_offset.offset, prev_value, block, load);
DBG_OPT_RAR(prev_load, load);
return replace_load(load, new_value);
}
......@@ -553,7 +554,7 @@ static changes_t try_load_after_load(track_load_env_t *env, ir_node *prev_load)
changes_t changed = replace_load(load, result_proj);
ir_node *const new_prev_value
= transform_previous_value(prev_mode, prev_base_offset.offset, load_mode,
base_offset->offset, result_proj, block);
base_offset->offset, result_proj, block, load);
exchange(original_proj, new_prev_value);
info->projs[pn_Load_res] = result_proj;
changed |= DF_CHANGED;
......
Supports Markdown
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