aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2010-09-15 17:42:41 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2010-09-15 17:42:41 +0200
commitcc99c5fefc057335b9ed6928d997c49bf3ff6575 (patch)
tree02e725f48b3beb800af69240bed12624b9ce5177 /gcc/expr.c
parent21b6aca3e1df3b774a2895c0d43d9397a2ff4ba0 (diff)
downloadgcc-cc99c5fefc057335b9ed6928d997c49bf3ff6575.zip
gcc-cc99c5fefc057335b9ed6928d997c49bf3ff6575.tar.gz
gcc-cc99c5fefc057335b9ed6928d997c49bf3ff6575.tar.bz2
re PR tree-optimization/45633 (internal compiler error: verify_stmts failed)
PR tree-optimization/45633 * tree-cfg.c (verify_gimple_assign_binary): Allow MINUS_EXPR with lhs and rhs1 pointer vector and rhs2 sizetype vector. * expr.c (expand_expr_real_2) <case PLUS_EXPR>: For pointer or vector pointer use TER to optimize pointer subtraction. * gcc.dg/vect/pr45633.c: New test. From-SVN: r164312
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index b1e87d1..16daddc 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -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. */