summaryrefslogtreecommitdiff
path: root/gcc/lambda.h
diff options
context:
space:
mode:
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2007-06-06 06:08:58 +0000
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2007-06-06 06:08:58 +0000
commit87cbf023f37936aac287f2bf03b1ede3307c33cd (patch)
treebd5186af1c19a3521332d48b13b46ab6820faad1 /gcc/lambda.h
parent540d5745fa907c24f1547406d85681e33b5e7968 (diff)
downloadgcc-87cbf023f37936aac287f2bf03b1ede3307c33cd.tar.gz
* lambda.h (build_linear_expr): New.
* lambda-code.c (lbv_to_gcc_expression, lle_to_gcc_expression): Use build_linear_expr, call fold and force_gimple_operand. (lambda_loopnest_to_gcc_loopnest): Check that there is something to insert. * testsuite/gcc.dg/tree-ssa/ltrans-6.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125355 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/lambda.h')
-rw-r--r--gcc/lambda.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/lambda.h b/gcc/lambda.h
index 3a691c24c1c..e6fbc8ff6ad 100644
--- a/gcc/lambda.h
+++ b/gcc/lambda.h
@@ -434,5 +434,32 @@ lambda_vector_lexico_pos (lambda_vector v,
return true;
}
+/* Given a vector of induction variables IVS, and a vector of
+ coefficients COEFS, build a tree that is a linear combination of
+ the induction variables. */
+
+static inline tree
+build_linear_expr (tree type, lambda_vector coefs, VEC (tree, heap) *ivs)
+{
+ unsigned i;
+ tree iv;
+ tree expr = fold_convert (type, integer_zero_node);
+
+ for (i = 0; VEC_iterate (tree, ivs, i, iv); i++)
+ {
+ int k = coefs[i];
+
+ if (k == 1)
+ expr = fold_build2 (PLUS_EXPR, type, expr, iv);
+
+ else if (k != 0)
+ expr = fold_build2 (PLUS_EXPR, type, expr,
+ fold_build2 (MULT_EXPR, type, iv,
+ build_int_cst (type, k)));
+ }
+
+ return expr;
+}
+
#endif /* LAMBDA_H */