2010-01-14 Sebastian Pop <sebastian.pop@amd.com>
PR middle-end/42681
* graphite-clast-to-gimple.c (gloog_error): New static variable.
(clast_to_gcc_expression): Do not build MULT_EXPR of POINTER_TYPE_P.
Set gloog_error when such an expression failed to be built.
(translate_clast): Early return when gloog_error is set.
(gloog): Clear gloog_error. When gloog_error is set, call
set_ifsese_condition to enable the original code. Return the status
of the code generation based on gloog_error.
* sese.c (set_ifsese_condition): New.
* sese.h (set_ifsese_condition): Declared.
* testsuite/g++.dg/graphite/pr42681.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155884
138bc75d-0d04-0410-961f-
82ee72b054a4
2010-01-14 Sebastian Pop <sebastian.pop@amd.com>
+ PR middle-end/42681
+ * graphite-clast-to-gimple.c (gloog_error): New static variable.
+ (clast_to_gcc_expression): Do not build MULT_EXPR of POINTER_TYPE_P.
+ Set gloog_error when such an expression failed to be built.
+ (translate_clast): Early return when gloog_error is set.
+ (gloog): Clear gloog_error. When gloog_error is set, call
+ set_ifsese_condition to enable the original code. Return the status
+ of the code generation based on gloog_error.
+ * sese.c (set_ifsese_condition): New.
+ * sese.h (set_ifsese_condition): Declared.
+
+ * testsuite/g++.dg/graphite/pr42681.C: New.
+
+2010-01-14 Sebastian Pop <sebastian.pop@amd.com>
+
PR middle-end/42732
* graphite-clast-to-gimple.c (gloog): Call scev_reset_htab and
rename_nb_iterations.
#include "graphite-clast-to-gimple.h"
#include "graphite-dependences.h"
+/* This flag is set when an error occurred during the translation of
+ CLAST to Gimple. */
+static bool gloog_error;
+
/* Verifies properties that GRAPHITE should maintain during translation. */
static inline void
newivs_index, params_index);
tree cst = gmp_cst_to_tree (type, t->val);
name = fold_convert (type, name);
- return fold_build2 (MULT_EXPR, type, cst, name);
+ if (!POINTER_TYPE_P (type))
+ return fold_build2 (MULT_EXPR, type, cst, name);
+
+ gloog_error = true;
+ return cst;
}
}
else
htab_t newivs_index, htab_t bb_pbb_mapping, int level,
htab_t params_index)
{
- if (!stmt)
+ if (!stmt || gloog_error)
return next_e;
if (CLAST_STMT_IS_A (stmt, stmt_root))
cloog_prog_clast pc;
timevar_push (TV_GRAPHITE_CODE_GEN);
+ gloog_error = false;
pc = scop_to_clast (scop);
recompute_all_dominators ();
graphite_verify ();
+ if (gloog_error)
+ set_ifsese_condition (if_region, integer_zero_node);
+
free (if_region->true_region);
free (if_region->region);
free (if_region);
num_no_dependency);
}
- return true;
+ return !gloog_error;
}
#endif
return if_region;
}
+/* Replaces the condition of the IF_REGION with CONDITION:
+ | if (CONDITION)
+ | true_region;
+ | else
+ | false_region;
+*/
+
+void
+set_ifsese_condition (ifsese if_region, tree condition)
+{
+ sese region = if_region->region;
+ edge entry = region->entry;
+ basic_block bb = entry->dest;
+ gimple last = last_stmt (bb);
+ gimple_stmt_iterator gsi = gsi_last_bb (bb);
+ gimple cond_stmt;
+
+ gcc_assert (gimple_code (last) == GIMPLE_COND);
+
+ gsi_remove (&gsi, true);
+ gsi = gsi_last_bb (bb);
+ condition = force_gimple_operand_gsi (&gsi, condition, true, NULL,
+ false, GSI_NEW_STMT);
+ cond_stmt = gimple_build_cond_from_tree (condition, NULL_TREE, NULL_TREE);
+ gsi = gsi_last_bb (bb);
+ gsi_insert_after (&gsi, cond_stmt, GSI_NEW_STMT);
+}
+
/* Returns the scalar evolution of T in REGION. Every variable that
is not defined in the REGION is considered a parameter. */
extern ifsese move_sese_in_condition (sese);
extern edge get_true_edge_from_guard_bb (basic_block);
extern edge get_false_edge_from_guard_bb (basic_block);
+extern void set_ifsese_condition (ifsese, tree);
static inline edge
if_region_entry (ifsese if_region)
--- /dev/null
+/* { dg-options "-O1 -fgraphite-identity -fno-loop-block -fno-loop-interchange -fno-loop-strip-mine" } */
+
+typedef long unsigned int size_t;
+inline void* operator new(size_t, void* __p) throw() { return __p; }
+
+struct A {
+ int i, j;
+ A() : i(0) {}
+};
+
+void Init(A *a)
+{
+ for (int i = 0; i < 20; i++) {
+ new (&a[i]) A;
+ a[i].j = 0;
+ }
+}