diff options
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 39 |
1 files changed, 25 insertions, 14 deletions
@@ -9290,7 +9290,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, rtx op0, op1, temp, decl_rtl; tree type; int unsignedp; - machine_mode mode; + machine_mode mode, dmode; enum tree_code code = TREE_CODE (exp); rtx subtarget, original_target; int ignore; @@ -9421,7 +9421,8 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, if (g == NULL && modifier == EXPAND_INITIALIZER && !SSA_NAME_IS_DEFAULT_DEF (exp) - && (optimize || DECL_IGNORED_P (SSA_NAME_VAR (exp))) + && (optimize || !SSA_NAME_VAR (exp) + || DECL_IGNORED_P (SSA_NAME_VAR (exp))) && stmt_is_replaceable_p (SSA_NAME_DEF_STMT (exp))) g = SSA_NAME_DEF_STMT (exp); if (g) @@ -9500,15 +9501,18 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, /* Ensure variable marked as used even if it doesn't go through a parser. If it hasn't be used yet, write out an external definition. */ - TREE_USED (exp) = 1; + if (exp) + TREE_USED (exp) = 1; /* Show we haven't gotten RTL for this yet. */ temp = 0; /* Variables inherited from containing functions should have been lowered by this point. */ - context = decl_function_context (exp); - gcc_assert (SCOPE_FILE_SCOPE_P (context) + if (exp) + context = decl_function_context (exp); + gcc_assert (!exp + || SCOPE_FILE_SCOPE_P (context) || context == current_function_decl || TREE_STATIC (exp) || DECL_EXTERNAL (exp) @@ -9532,7 +9536,8 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, decl_rtl = use_anchored_address (decl_rtl); if (modifier != EXPAND_CONST_ADDRESS && modifier != EXPAND_SUM - && !memory_address_addr_space_p (DECL_MODE (exp), + && !memory_address_addr_space_p (exp ? DECL_MODE (exp) + : GET_MODE (decl_rtl), XEXP (decl_rtl, 0), MEM_ADDR_SPACE (decl_rtl))) temp = replace_equiv_address (decl_rtl, @@ -9543,12 +9548,17 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, if the address is a register. */ if (temp != 0) { - if (MEM_P (temp) && REG_P (XEXP (temp, 0))) + if (exp && MEM_P (temp) && REG_P (XEXP (temp, 0))) mark_reg_pointer (XEXP (temp, 0), DECL_ALIGN (exp)); return temp; } + if (exp) + dmode = DECL_MODE (exp); + else + dmode = TYPE_MODE (TREE_TYPE (ssa_name)); + /* If the mode of DECL_RTL does not match that of the decl, there are two cases: we are dealing with a BLKmode value that is returned in a register, or we are dealing with @@ -9556,22 +9566,23 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, of the wanted mode, but mark it so that we know that it was already extended. */ if (REG_P (decl_rtl) - && DECL_MODE (exp) != BLKmode - && GET_MODE (decl_rtl) != DECL_MODE (exp)) + && dmode != BLKmode + && GET_MODE (decl_rtl) != dmode) { machine_mode pmode; /* Get the signedness to be used for this variable. Ensure we get the same mode we got when the variable was declared. */ - if (code == SSA_NAME - && (g = SSA_NAME_DEF_STMT (ssa_name)) - && gimple_code (g) == GIMPLE_CALL - && !gimple_call_internal_p (g)) + if (code != SSA_NAME) + pmode = promote_decl_mode (exp, &unsignedp); + else if ((g = SSA_NAME_DEF_STMT (ssa_name)) + && gimple_code (g) == GIMPLE_CALL + && !gimple_call_internal_p (g)) pmode = promote_function_mode (type, mode, &unsignedp, gimple_call_fntype (g), 2); else - pmode = promote_decl_mode (exp, &unsignedp); + pmode = promote_ssa_mode (ssa_name, &unsignedp); gcc_assert (GET_MODE (decl_rtl) == pmode); temp = gen_lowpart_SUBREG (mode, decl_rtl); |