diff options
author | Jan Sjodin <jan.sjodin@amd.com> | 2007-06-06 06:08:58 +0000 |
---|---|---|
committer | Sebastian Pop <spop@gcc.gnu.org> | 2007-06-06 06:08:58 +0000 |
commit | 69f2880c76592888802df4ab3621b9f32cf1523b (patch) | |
tree | bd5186af1c19a3521332d48b13b46ab6820faad1 /gcc/lambda.h | |
parent | 518a0b783878a8e1056a79ff31f18170775530a3 (diff) | |
download | gcc-69f2880c76592888802df4ab3621b9f32cf1523b.zip gcc-69f2880c76592888802df4ab3621b9f32cf1523b.tar.gz gcc-69f2880c76592888802df4ab3621b9f32cf1523b.tar.bz2 |
lambda.h (build_linear_expr): New.
* 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.
Co-Authored-By: Sebastian Pop <sebpop@gmail.com>
From-SVN: r125355
Diffstat (limited to 'gcc/lambda.h')
-rw-r--r-- | gcc/lambda.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/lambda.h b/gcc/lambda.h index 3a691c2..e6fbc8f 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 */ |