isl_ast_expr_from_aff: try harder to use isl_ast_op_pdiv_{q,r}
commit330a2f76ee639da3fa2c7084dcd41675eea3d970
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 28 Sep 2012 18:19:01 +0000 (28 20:19 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 29 Sep 2012 16:08:49 +0000 (29 18:08 +0200)
tree1197f810ddfd67d9e7662d137039db14caa05c03
parent8d21eadb2ba515d655d5f742fd97383f83e86c00
isl_ast_expr_from_aff: try harder to use isl_ast_op_pdiv_{q,r}

When generating C code, we prefer to generate "/" (or "%") rather
than "floord" because "floord" has an implicit condition on the
sign of the first argument.
We would already generate isl_ast_op_pdiv_q instead of isl_ast_op_fdiv_q
if we detect that the first argument is non-negative.
Now, we also check if the first argument is smaller than the second.
If so, we can rewrite

floor(e/d) = -ceil(-e/d) = -floor((-e + d - 1)/d)

and still use isl_ast_op_pdiv_q.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
14 files changed:
isl_ast_build_expr.c
test_inputs/codegen/cloog/jacobi-shared.c
test_inputs/codegen/cloog/nul_complex1.c
test_inputs/codegen/cloog/reservoir-cholesky2.c
test_inputs/codegen/cloog/reservoir-lim-lam3.c
test_inputs/codegen/omega/dagstuhl1-1.c
test_inputs/codegen/omega/hpf-0.c
test_inputs/codegen/omega/lefur00-0.c
test_inputs/codegen/omega/lefur01-0.c
test_inputs/codegen/omega/lefur01-1.c
test_inputs/codegen/omega/lefur03-0.c
test_inputs/codegen/omega/lefur04-0.c
test_inputs/codegen/omega/p.delft-0.c
test_inputs/codegen/omega/p.delft2-0.c