Commit fc81a369 by Richard Henderson Committed by Richard Henderson

re PR tree-optimization/42215 (internal compiler error: verify_stmts failed with…

re PR tree-optimization/42215 (internal compiler error: verify_stmts failed with -O2 -ftree-loop-distribution)

        PR tree-opt/42215
        * tree-loop-distribution.c (build_size_arg_loc): Tidy.
        (generate_memset_zero): Convert to sizetype properly.  Tidy.

From-SVN: r154925
parent cdd0c4d3
2009-12-02 Richard Henderson <rth@redhat.com>
PR tree-opt/42215
* tree-loop-distribution.c (build_size_arg_loc): Tidy.
(generate_memset_zero): Convert to sizetype properly. Tidy.
2009-12-02 Richard Guenther <rguenther@suse.de> 2009-12-02 Richard Guenther <rguenther@suse.de>
* lto-streamer-out.c (pack_ts_decl_common_value_fields): * lto-streamer-out.c (pack_ts_decl_common_value_fields):
/* { dg-do compile } */
/* { dg-options "-O2 -ftree-loop-distribution" } */
extern int A[];
extern int B[];
void f(int i)
{
while (i-- > 0) {
A[i] = 0;
B[i] = 0;
}
}
...@@ -222,19 +222,20 @@ generate_loops_for_partition (struct loop *loop, bitmap partition, bool copy_p) ...@@ -222,19 +222,20 @@ generate_loops_for_partition (struct loop *loop, bitmap partition, bool copy_p)
/* Build the size argument for a memset call. */ /* Build the size argument for a memset call. */
static inline tree static inline tree
build_size_arg_loc (location_t loc, tree nb_iter, tree op, gimple_seq* stmt_list) build_size_arg_loc (location_t loc, tree nb_iter, tree op,
gimple_seq *stmt_list)
{ {
tree nb_bytes; gimple_seq stmts;
gimple_seq stmts = NULL; tree x;
nb_bytes = fold_build2_loc (loc, MULT_EXPR, size_type_node, x = fold_build2_loc (loc, MULT_EXPR, size_type_node,
fold_convert_loc (loc, size_type_node, nb_iter), fold_convert_loc (loc, size_type_node, nb_iter),
fold_convert_loc (loc, size_type_node, fold_convert_loc (loc, size_type_node,
TYPE_SIZE_UNIT (TREE_TYPE (op)))); TYPE_SIZE_UNIT (TREE_TYPE (op))));
nb_bytes = force_gimple_operand (nb_bytes, &stmts, true, NULL); x = force_gimple_operand (x, &stmts, true, NULL);
gimple_seq_add_seq (stmt_list, stmts); gimple_seq_add_seq (stmt_list, stmts);
return nb_bytes; return x;
} }
/* Generate a call to memset. Return true when the operation succeeded. */ /* Generate a call to memset. Return true when the operation succeeded. */
...@@ -243,12 +244,11 @@ static bool ...@@ -243,12 +244,11 @@ static bool
generate_memset_zero (gimple stmt, tree op0, tree nb_iter, generate_memset_zero (gimple stmt, tree op0, tree nb_iter,
gimple_stmt_iterator bsi) gimple_stmt_iterator bsi)
{ {
tree addr_base; tree addr_base, nb_bytes;
tree nb_bytes = NULL;
bool res = false; bool res = false;
gimple_seq stmts = NULL, stmt_list = NULL; gimple_seq stmt_list = NULL, stmts;
gimple fn_call; gimple fn_call;
tree mem, fndecl, fntype, fn; tree mem, fn;
gimple_stmt_iterator i; gimple_stmt_iterator i;
struct data_reference *dr = XCNEW (struct data_reference); struct data_reference *dr = XCNEW (struct data_reference);
location_t loc = gimple_location (stmt); location_t loc = gimple_location (stmt);
...@@ -259,34 +259,35 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter, ...@@ -259,34 +259,35 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter,
goto end; goto end;
/* Test for a positive stride, iterating over every element. */ /* Test for a positive stride, iterating over every element. */
if (integer_zerop (fold_build2_loc (loc, if (integer_zerop (size_binop (MINUS_EXPR,
MINUS_EXPR, integer_type_node, DR_STEP (dr), fold_convert (sizetype, DR_STEP (dr)),
TYPE_SIZE_UNIT (TREE_TYPE (op0))))) TYPE_SIZE_UNIT (TREE_TYPE (op0)))))
{ {
tree offset = fold_convert_loc (loc, sizetype, addr_base = fold_convert_loc (loc, sizetype,
size_binop_loc (loc, PLUS_EXPR, size_binop_loc (loc, PLUS_EXPR,
DR_OFFSET (dr), DR_OFFSET (dr),
DR_INIT (dr))); DR_INIT (dr)));
addr_base = fold_build2_loc (loc, POINTER_PLUS_EXPR, addr_base = fold_build2_loc (loc, POINTER_PLUS_EXPR,
TREE_TYPE (DR_BASE_ADDRESS (dr)), TREE_TYPE (DR_BASE_ADDRESS (dr)),
DR_BASE_ADDRESS (dr), offset); DR_BASE_ADDRESS (dr), addr_base);
nb_bytes = build_size_arg_loc (loc, nb_iter, op0, &stmt_list);
} }
/* Test for a negative stride, iterating over every element. */ /* Test for a negative stride, iterating over every element. */
else if (integer_zerop (fold_build2_loc (loc, PLUS_EXPR, integer_type_node, else if (integer_zerop (size_binop (PLUS_EXPR,
TYPE_SIZE_UNIT (TREE_TYPE (op0)), TYPE_SIZE_UNIT (TREE_TYPE (op0)),
DR_STEP (dr)))) fold_convert (sizetype, DR_STEP (dr)))))
{ {
nb_bytes = build_size_arg_loc (loc, nb_iter, op0, &stmt_list); nb_bytes = build_size_arg_loc (loc, nb_iter, op0, &stmt_list);
addr_base = size_binop_loc (loc, PLUS_EXPR, DR_OFFSET (dr), DR_INIT (dr));
addr_base = fold_build2_loc (loc, MINUS_EXPR, sizetype, addr_base,
fold_convert_loc (loc, sizetype, nb_bytes));
addr_base = force_gimple_operand (addr_base, &stmts, true, NULL);
gimple_seq_add_seq (&stmt_list, stmts);
addr_base = size_binop_loc (loc, PLUS_EXPR, DR_OFFSET (dr), DR_INIT (dr));
addr_base = fold_convert_loc (loc, sizetype, addr_base);
addr_base = size_binop_loc (loc, MINUS_EXPR, addr_base,
fold_convert_loc (loc, sizetype, nb_bytes));
addr_base = fold_build2_loc (loc, POINTER_PLUS_EXPR, addr_base = fold_build2_loc (loc, POINTER_PLUS_EXPR,
TREE_TYPE (DR_BASE_ADDRESS (dr)), TREE_TYPE (DR_BASE_ADDRESS (dr)),
DR_BASE_ADDRESS (dr), addr_base); DR_BASE_ADDRESS (dr), addr_base);
} }
else else
goto end; goto end;
...@@ -294,12 +295,7 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter, ...@@ -294,12 +295,7 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter,
mem = force_gimple_operand (addr_base, &stmts, true, NULL); mem = force_gimple_operand (addr_base, &stmts, true, NULL);
gimple_seq_add_seq (&stmt_list, stmts); gimple_seq_add_seq (&stmt_list, stmts);
fndecl = implicit_built_in_decls [BUILT_IN_MEMSET]; fn = build_fold_addr_expr (implicit_built_in_decls [BUILT_IN_MEMSET]);
fntype = TREE_TYPE (fndecl);
fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
if (!nb_bytes)
nb_bytes = build_size_arg_loc (loc, nb_iter, op0, &stmt_list);
fn_call = gimple_build_call (fn, 3, mem, integer_zero_node, nb_bytes); fn_call = gimple_build_call (fn, 3, mem, integer_zero_node, nb_bytes);
gimple_seq_add_stmt (&stmt_list, fn_call); gimple_seq_add_stmt (&stmt_list, fn_call);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment