Commit b2bc7cd8 authored by Matthias Braun's avatar Matthias Braun
Browse files

use get_reference_mode_unsigned_eq() for offset calculations

parent 81f3c0dd
......@@ -684,9 +684,10 @@ static void create_stores_for_type(ir_graph *irg, ir_type *type)
cons_none);
ir_node *mem0 = new_r_Proj(store0, mode_M, pn_Store_M);
size_t offset = get_mode_size_bits(mode)/8;
ir_mode *addr_mode = get_irn_mode(addr);
ir_node *cnst = new_r_Const_long(irg, addr_mode, offset);
ir_node *next_addr = new_r_Add(start_block, addr, cnst, addr_mode);
ir_mode *mode_ref = get_irn_mode(addr);
ir_mode *mode_offs = get_reference_mode_unsigned_eq(mode_ref);
ir_node *cnst = new_r_Const_long(irg, mode_offs, offset);
ir_node *next_addr = new_r_Add(start_block, addr, cnst, mode_ref);
ir_node *store1 = new_r_Store(start_block, mem0, next_addr, val1,
cons_none);
mem = new_r_Proj(store1, mode_M, pn_Store_M);
......
......@@ -63,7 +63,7 @@ static void lower_small_copyb_node(ir_node *irn)
ir_node *addr_src = get_CopyB_src(irn);
ir_node *addr_dst = get_CopyB_dst(irn);
ir_node *mem = get_CopyB_mem(irn);
ir_mode *addr_mode = get_irn_mode(addr_src);
ir_mode *mode_ref = get_irn_mode(addr_src);
unsigned mode_bytes =
allow_misalignments ? native_mode_bytes : get_type_alignment_bytes(tp);
unsigned size = get_type_size_bytes(tp);
......@@ -72,18 +72,20 @@ static void lower_small_copyb_node(ir_node *irn)
while (offset < size) {
ir_mode *mode = get_ir_mode(mode_bytes);
for (; offset + mode_bytes <= size; offset += mode_bytes) {
ir_mode *mode_ref_int = get_reference_mode_unsigned_eq(mode_ref);
/* construct offset */
ir_node *addr_const = new_r_Const_long(irg, mode_Iu, offset);
ir_node *addr_const = new_r_Const_long(irg, mode_ref_int, offset);
ir_node *add = new_r_Add(block, addr_src, addr_const,
addr_mode);
mode_ref);
ir_node *load = new_r_Load(block, mem, add, mode, cons_none);
ir_node *load_res = new_r_Proj(load, mode, pn_Load_res);
ir_node *load_mem = new_r_Proj(load, mode_M, pn_Load_M);
ir_node *addr_const2 = new_r_Const_long(irg, mode_Iu, offset);
ir_node *addr_const2 = new_r_Const_long(irg, mode_ref_int, offset);
ir_node *add2 = new_r_Add(block, addr_dst, addr_const2,
addr_mode);
mode_ref);
ir_node *store = new_r_Store(block, load_mem, add2, load_res,
cons_none);
......
......@@ -586,8 +586,10 @@ static ir_node *try_update_ptr_CopyB(ir_node *load, ir_node *load_base_ptr,
*/
ir_graph *irg = get_irn_irg(load);
ir_node *block = get_nodes_block(load);
ir_node *cnst = new_r_Const_long(irg, mode_Is, load_src_offset);
ir_node *new_load_ptr = new_r_Add(block, src_base_ptr, cnst, mode_P);
ir_mode *mode_ref = get_irn_mode(src_base_ptr);
ir_mode *mode_ref_int = get_reference_mode_unsigned_eq(mode_ref);
ir_node *cnst = new_r_Const_long(irg, mode_ref_int, load_src_offset);
ir_node *new_load_ptr = new_r_Add(block, src_base_ptr, cnst, mode_ref);
return new_load_ptr;
}
......@@ -1455,12 +1457,13 @@ static changes_t optimize_conv_load(ir_node *conv)
if (be_get_backend_param()->byte_order_big_endian) {
if (bits_diff % 8 != 0)
return NO_CHANGES;
ir_graph *irg = get_irn_irg(conv);
ir_node *ptr = get_Load_ptr(load);
ir_mode *mode = get_irn_mode(ptr);
ir_node *delta = new_r_Const_long(irg, mode, bits_diff/8);
ir_node *block = get_nodes_block(load);
ir_node *add = new_r_Add(block, ptr, delta, mode);
ir_graph *irg = get_irn_irg(conv);
ir_node *ptr = get_Load_ptr(load);
ir_mode *mode = get_irn_mode(ptr);
ir_mode *mode_offs = get_reference_mode_unsigned_eq(mode);
ir_node *delta = new_r_Const_long(irg, mode_offs, bits_diff/8);
ir_node *block = get_nodes_block(load);
ir_node *add = new_r_Add(block, ptr, delta, mode);
set_Load_ptr(load, add);
}
set_Load_mode(load, mode);
......
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