Commit 8365ace0 authored by Andreas Zwinkau's avatar Andreas Zwinkau
Browse files

Fix C/bitfield4

Load-Store-Opt now shifts constant loads from bitfields accordingly.
parent 762b472f
...@@ -1183,8 +1183,20 @@ static unsigned optimize_load(ir_node *load) ...@@ -1183,8 +1183,20 @@ static unsigned optimize_load(ir_node *load)
free_compound_graph_path(path); free_compound_graph_path(path);
} }
} }
if (value != NULL) if (value != NULL) {
ir_graph *irg = get_irn_irg(load);
value = can_replace_load_by_const(load, value); value = can_replace_load_by_const(load, value);
if (value != NULL && is_Sel(ptr) &&
!is_irg_state(irg, IR_GRAPH_STATE_IMPLICIT_BITFIELD_MASKING)) {
/* frontend has inserted masking operations after bitfield accesses,
* so we might have to shift the const. */
unsigned char bit_offset = get_entity_offset_bits_remainder(get_Sel_entity(ptr));
ir_tarval *tv_old = get_Const_tarval(value);
ir_tarval *tv_offset = new_tarval_from_long(bit_offset, mode_Bu);
ir_tarval *tv_new = tarval_shl(tv_old, tv_offset);
value = new_r_Const(irg, tv_new);
}
}
} }
} }
} }
......
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