From b81587dedc80a12971be6bc52d94f2ec648aad18 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Tue, 27 Nov 2012 22:42:40 +0100 Subject: [PATCH] ia32: Clean up ia32_try_create_Immediate(). --- ir/be/ia32/ia32_common_transform.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/ir/be/ia32/ia32_common_transform.c b/ir/be/ia32/ia32_common_transform.c index 0b4f7cfb7..cff3f0a7b 100644 --- a/ir/be/ia32/ia32_common_transform.c +++ b/ir/be/ia32/ia32_common_transform.c @@ -858,18 +858,12 @@ int ia32_prevents_AM(ir_node *const block, ir_node *const am_candidate, ir_node *ia32_try_create_Immediate(ir_node *node, char immediate_constraint_type) { - long val = 0; - ir_entity *symconst_ent = NULL; - ir_mode *mode; - ir_node *cnst = NULL; - ir_node *symconst = NULL; - ir_node *new_node; - - mode = get_irn_mode(node); - if (!mode_is_int(mode) && !mode_is_reference(mode)) { + ir_mode *const mode = get_irn_mode(node); + if (!mode_is_int(mode) && !mode_is_reference(mode)) return NULL; - } + ir_node *cnst; + ir_node *symconst; if (is_Const(node)) { cnst = node; symconst = NULL; @@ -886,11 +880,14 @@ ir_node *ia32_try_create_Immediate(ir_node *node, char immediate_constraint_type } else if (is_SymConst_addr_ent(left) && is_Const(right)) { cnst = right; symconst = left; + } else { + return NULL; } } else { return NULL; } + long val = 0; if (cnst != NULL) { ir_tarval *offset = get_Const_tarval(cnst); if (!tarval_is_long(offset)) { @@ -902,17 +899,15 @@ ir_node *ia32_try_create_Immediate(ir_node *node, char immediate_constraint_type if (!check_immediate_constraint(val, immediate_constraint_type)) return NULL; } + + ir_entity *symconst_ent = NULL; if (symconst != NULL) { - if (immediate_constraint_type != 'i') { - /* we need full 32bits for symconsts */ + /* we need full 32bits for symconsts */ + if (immediate_constraint_type != 'i') return NULL; - } symconst_ent = get_SymConst_entity(symconst); } - if (cnst == NULL && symconst == NULL) - return NULL; - new_node = ia32_create_Immediate(symconst_ent, 0, val); - return new_node; + return ia32_create_Immediate(symconst_ent, 0, val); } -- 2.20.1