From af2736daec0e6579a006bd8d4567c977c8e56c45 Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Thu, 8 Jun 2017 16:29:05 +0100 Subject: Fix bit field bug --- src/ir.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index e94f84e3b..bcea8a515 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -1902,12 +1902,14 @@ irValue *ir_addr_load(irProcedure *proc, irAddr addr) { return v; } + GB_ASSERT(8 > bit_inset); + irValue *shift_amount = ir_value_constant(a, int_type, exact_value_i64(bit_inset)); irValue *first_byte = ir_emit_load(proc, bytes); - irValue *res = ir_emit_arith(proc, Token_Shr, first_byte, ir_const_int(a, 8 - bit_inset), int_type); + irValue *res = ir_emit_arith(proc, Token_Shr, first_byte, shift_amount, int_type); irValue *remaining_bytes = ir_emit_load(proc, ir_emit_conv(proc, ir_emit_ptr_offset(proc, bytes, v_one), int_ptr)); - remaining_bytes = ir_emit_arith(proc, Token_Shl, remaining_bytes, ir_const_int(a, bit_inset), int_type); + remaining_bytes = ir_emit_arith(proc, Token_Shl, remaining_bytes, shift_amount, int_type); return ir_emit_arith(proc, Token_Or, res, remaining_bytes, int_type); } -- cgit v1.2.3