diff options
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -7572,6 +7572,24 @@ expand_expr_real_2 (sepops ops, rtx target, enum machine_mode tmode, } } + /* Use TER to expand pointer addition of a negated value + as pointer subtraction. */ + if ((POINTER_TYPE_P (TREE_TYPE (treeop0)) + || (TREE_CODE (TREE_TYPE (treeop0)) == VECTOR_TYPE + && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (treeop0))))) + && TREE_CODE (treeop1) == SSA_NAME + && TYPE_MODE (TREE_TYPE (treeop0)) + == TYPE_MODE (TREE_TYPE (treeop1))) + { + gimple def = get_def_for_expr (treeop1, NEGATE_EXPR); + if (def) + { + treeop1 = gimple_assign_rhs1 (def); + code = MINUS_EXPR; + goto do_minus; + } + } + /* No sense saving up arithmetic to be done if it's all in the wrong mode to form part of an address. And force_operand won't know whether to sign-extend or @@ -7593,6 +7611,7 @@ expand_expr_real_2 (sepops ops, rtx target, enum machine_mode tmode, return REDUCE_BIT_FIELD (simplify_gen_binary (PLUS, mode, op0, op1)); case MINUS_EXPR: + do_minus: /* For initializers, we are allowed to return a MINUS of two symbolic constants. Here we handle all cases when both operands are constant. */ |